To control iAd in your view controller you can setup a delegate to listen for iAd states:
@interface MyViewController : UIViewController <ADBannerViewDelegate>
...
@property (nonatomic, weak) IBOutlet ADBannerView* banner;
@end
then in your implementation file:
@implementation MyViewController
- (void)viewDidLoad
{
...
[_banner setHidden:YES];
_banner.delegate = self;
}
...
#pragma mark - ADBannerViewDelegate implementation
- (void)bannerView:(ADBannerView*)banner didFailToReceiveAdWithError:(NSError*)error
{
// iAd is not available, so we are going to hide it to get rid of ugly white rectangle
[_banner setHidden:YES];
// Here you can add your logic to show your other ads
}
- (void)bannerViewDidLoadAd:(ADBannerView*)banner
{
// iAd is available, lets show it
[_banner setHidden:NO];
// Here you can add your logic to hide your other ads
}
@end
Also I normally keep just one instance of ADBannerView, have it in my App Delegate and once some view controller appears on a screen - I simply add that ADBannerView to view hierarchy of view controller and remove it when view controller disappears.