In iOS7, the iAds framework includes the category -[UIViewController canDisplayBannerAds]
.
What does this category do and how should I use it?
The headers for canDisplayBannerAds
state:
Set this to enable automatic management of banner ad display with the view controller. It's important to note that this will modify the view hierarchy of the view controller by inserting a new container view above the view controller's view. The impact is that the view controller's view property will no longer return the originally provided view, it will return the new container. To access the original view, use the originalContentView property.
What is not clear is that automatic management also refers to instantiating and inserting an ADBannerView
into your view hierarchy. You do not need to instantiate an ADBannerView
, and you do not need an ADBannerView property or instance variable.
You will still want to adhere to the ADBannerViewDelegate
protocol in your view controller so you can pause your application when the user taps the ad, and then resume when the fullscreen ad goes away.
Update: Unless you want to walk through the view hierarchy looking for the automatically inserted ADBannerView
to set your view controller as a delegate, you can also cut the ADBannerViewDelegate
protocol methods.
You actually need to look at the docs for originalContentView to learn this:
When a view controller enables banner ads, the system puts the view controller’s content view inside of a new content view that the system manages. This allows the system to dynamically resize the original content view when a banner ad is displayed, as well as managing the display of the banner ad itself. This property provides access to the original content view, rather than the containing view that manages banner ad display.