问题
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