My program switches back and forth between two ViewControllers, each with an iAd BannerView from the Storyboard. If I switch back and forth about five times, I get the following error:
WARNING: More than 10 instances of
ADBannerView
orADInterstitialView
currently exist. This is a misuse of the iAd API, and ad performance will suffer as a result. This message is printed only once.
I instantiate the ADBannerView like this:
@interface GradeTableViewController : UIViewController<ADBannerViewDelegate>
@property (strong, nonatomic) IBOutlet ADBannerView *adBannerView;
@end
@implementation GradeTableViewController
@synthesize adBannerView;
- (void)viewDidLoad{
[super viewDidLoad];
adBannerView=[[ADBannerView alloc]init];
adBannerView.delegate=self;
adBannerView.hidden=NO;
}
The following code is supposed to release the ADBannerView object:
- (void) viewWillDisappear:(BOOL)animated{
[adBannerView removeFromSuperview];
adBannerView.delegate=nil;
adBannerView=nil;
}
However, as evidenced by the error message above, 'viewWillDisappear' fails to correctly dealloc/release 'adBannerView'. How should I release an 'ADBannerView' object correctly to prevent the error message from occurring?