iAd + multiple UITableViewControllers

你说的曾经没有我的故事 提交于 2019-12-12 01:35:43

问题


I've been looking for this for awhile now.. Is there a way to add iAds (or AdMob, or any other mobile advertising thing) to UITableViewControllers ? At the most, my app goes about 3 or 4 levels deep, and I'd like to keep showing ads throughout all levels, without sending new ad requests each time (most solutions do this).

Thanks in advance!


回答1:


I know this question is old, but for anyone else that is curious and ran into this: You simply need to retain the instances between view transitions. I've written a simple singleton class that does exactly this because I was running into the same issues. It manages both iAds and AdMob ads in a single ad container that you can shuttle around your app without having to worry about creating and destroying multiple instances of your ads. When you move from one view to another, simply call one line of code in viewDidAppear or somewhere similar. It will automatically remove the ad container from the old view and add it to the new view, retaining the same ad throughout the life of the app session.

Before this method, I was simply creating new ad instances (for both iAd and AdMob) every time I went to a new view. Definitely not ideal.




回答2:


What do you means by "3 or 4 levels" ? you mean 3 or 4 "screens" (so a lot of cells ?)

Maybe the best solution is to add your iAd / Admob view below the UITableView. But I NEVER use UITableViewControllers but UITableView (it always add problems using this controller).

So maybe you could have an UIViewController and then inside an UITableView and below the iAd view ?

UIViewController
-> UITableView
-> iAd/Admob View



来源:https://stackoverflow.com/questions/4918726/iad-multiple-uitableviewcontrollers

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