如何将AdMob广告添加到UITableView [英] How to add AdMob ads to a UITableView

查看:173
本文介绍了如何将AdMob广告添加到UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将AdMob广告添加到表格视图中。

I am trying to add an AdMob ad to a table view.

我希望它显示在每个第10个单元格中。 (例如,如果你有免费版的Reddit应用程序,就像它一样)。

I would like it to show up in every 10th cell. (Eg. like how it is in the Free version of the Reddit App if you have it).

我试图按照AdMob文档但我没有幸运的是,我确信有一些我不知道的事情。

I tried to follow the AdMob documentation but I didn't have any luck and I'm sure there is something I am missing.

有没有人可以通过一种简单的方式来解决这个问题?
谢谢!

Could anyone shine some light on a simple way to do this? Thanks!

推荐答案

我使用的代码基本上是这样的:

I've used code basically like this:

int row = [indexpath row];

if (0 == (row % 10)) {  // or 9 == if you don't want the first cell to be an ad!
    static NSString *MyIdentifier = @"AdCell";
    cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
    }
    [cell.contentView addSubview:[AdMobView requestAdWithDelegate:self]];
} else {
     // make your normal cells
}

这篇关于如何将AdMob广告添加到UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆