Hiding iAd banners when ads are not available
Q: When and how should I hide iAd banners?
A: When and how should I hide iAd banners?
You should hide your banner view whenever ad content is not available; this includes:
When the banner view is loaded from a xib file, as ad content may not yet be available to the app (you can hide the banner in your view controller's
-viewDidLoad
method)When an error occurs, such as the banner view failing to load a new ad (you can hide the banner in the ADBannerView's
bannerView:didFailToReceiveAdWithError:
delegate method)
You can hide the banner view by following the steps below.
First, check if your banner view has already downloaded an ad from ADBannerView
's bannerLoaded
property. If it has not, you can proceed to hide the banner.
To hide the banner view, you should:
Resize your banner view's frame to be offscreen
Resize your content view's frame to cover the space originally hosting the banner
Specifically, if your banner is at the bottom of the screen, you should move the frame of the banner view down by the height of the banner; if your banner is at the top of the screen, you should move the frame of the banner view up by the height of the banner.
For a code example, see Sample Code "iAdSuite". For more information on the banner view lifecycle, see theiAd Programming Guide.
Document Revision History
Date | Notes |
---|---|
2010-09-14 | Updated for iOS 4.1. Move the frame instead of the center of the banner. |
2010-08-19 | New document that describes how to hide an iAd banner views when ads are not available. |
Copyright © 2010 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2010-09-14