问题
I'd like to occasionally hide an ADBannerView
. I'm thinking about banner.hidden = YES
and similar to un-hide. I'm concerned that Apple will frown upon this because receiving and "displaying" ads while the banner is hidden seems questionable.
In bannerView:didFailToReceiveAdWithError:
I'm animating the banner off the screen bottom. I'm open to doing this instead of using the hidden property if it's somehow better.
Perhaps it's possible to tell the banner to stop requesting ads. Unfortunately nothing jumped out at me while looking over ADBannerView.h
.
What's the best way to programatically hide ADBannerView
?
回答1:
The way to tell a banner view to stop receiving ads is to destroy it when not needed, as stated in the iAd Programming Guide [with bold emphasis added by me]:
When designing your application, keep the following principles in mind:
- Only create a banner view when you intend to display it to the user. Otherwise, it may cycle through ads and deplete the list of available advertising for your application.
- If the user navigates from a screen of content with a banner view to a screen that does not have a banner view, and you expect them to be on that screen for a long period of time, remove the banner view from the view hierarchy, set its delegate to nil and release it before transitioning to the new screen of content. More generally, avoid keeping a banner view around when it is invisible to the user.
来源:https://stackoverflow.com/questions/11197601/programmatically-hiding-apple-iad-adbannerview