Reputation: 20746
I want to show iAd Banner View at the bottom of the screen. Also I want to hide it before the first bannerViewDidLoadAd
and after bannerView:didFailToReceiveAdWithError
methods calls and restore it after any further bannerViewDidLoadAd
method calls. What is the correct way to achieve such behavior?
This is what I've tried:
Add iAd Banner View to the view controller via interface builder in XCode and choose view contoller as the delegate of this view
Add the following functions to the view contoller's implementation -- https://gist.github.com/ellneal/1082499
Add the calls to this methods to the bannerViewDidLoadAd
and bannerView:didFailToReceiveAdWithError
:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
[self showBannerView:banner animated:YES];
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
[self hideBannerView:banner animated:YES];
}
In this case I see a blank screen instead of ad before bannerViewDidLoadAd method was called and the iAd Banner View doesn't appear again when the connection established again (I think that it's because of removeFromSuperview
method call). How can I fix it? Maybe there is a more correct way to achieve such behavior?
Thanks in advance.
Upvotes: 0
Views: 142
Reputation: 7003
If possible, you should consider using setCanDisplayAds:
on your view controller. See Apple's documentation.
Import iAd and set the property on your root view controller, or on the content view controller you wish to display ads at the bottom of.
Upvotes: 1