如何将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
}