如何在 iOS 的 TableView 中使用 AdMob 横幅广告?

Posted

技术标签:

【中文标题】如何在 iOS 的 TableView 中使用 AdMob 横幅广告?【英文标题】:How to use AdMob Banner Ads in TableView in iOS? 【发布时间】:2019-07-27 07:20:52 【问题描述】:

我想在表格视图中的每 5 个结果之间展示不同的广告 我在我的 ios 项目中使用了 admob 横幅广告 Tableview 在每 5 个结果后显示相同的广告,即使我使用不同的广告单元 ID 在每 5 行后加载广告。

有什么解决方案可以在 5 行后获得不同的广告?

【问题讨论】:

【参考方案1】:

在 cellForRowAtIndexPath 中,每 5 行设置 admob 横幅单元格

喜欢这个

    switch(indexPath.row) 
       case 5, 10, 15...: // every 5 rows, put admob banner cell
           let cell = [tableView dequeueReusableCellWithIdentifier: @"AdmobBannerTableViewCell"];
           return cell;
       case 1,... : // other rows...
           let cell = [tableView dequeueReusableCellWithIdentifier: @"AnotherTableViewCell"];
           return cell;
    

【讨论】:

以上是关于如何在 iOS 的 TableView 中使用 AdMob 横幅广告?的主要内容,如果未能解决你的问题,请参考以下文章