Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
750 views
in Technique[技术] by (71.8m points)

ios - What does the iAd `UIViewController` category `canDisplayBannerAds` do?

In iOS7, the iAds framework includes the category -[UIViewController canDisplayBannerAds].

What does this category do and how should I use it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...