gpt4 book ai didi

iphone - 如何将 AdMob 广告添加到 UITableView

转载 作者:行者123 更新时间:2023-12-03 18:41:53 24 4
gpt4 key购买 nike

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

我希望它出现在每 10 个单元格中。 (例如,就像 Reddit 应用程序的免费版本中的情况一样,如果您有的话)。

我尝试按照 AdMob 文档进行操作,但运气不佳,而且我确信我遗漏了一些内容。

有人能提供一些简单的方法来做到这一点吗?谢谢!

最佳答案

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

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
}

关于iphone - 如何将 AdMob 广告添加到 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1583583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com