How to add AdMob ads to a UITableView

╄→гoц情女王★ 提交于 2019-12-20 08:53:06

问题


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

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).

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!


回答1:


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
}


来源:https://stackoverflow.com/questions/1583583/how-to-add-admob-ads-to-a-uitableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!