1

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 or ADInterstitialView 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?

Alekxos
  • 512
  • 6
  • 13
  • 1
    you should be using the ADBannerView's delegate methods instead of the UIViewController control methods – user2277872 Apr 06 '14 at 00:51
  • Should I completely delete the above UIViewController code? If so, how can I use the AppDelegate to implement a shared ADBannerView? I was planning on replacing 'adBannerView=[[ADBannerView alloc] init]' in the VC with 'adBannerView=[[self appdelegate] sharedAd]'. – Alekxos Apr 06 '14 at 01:41
  • @Alekxos did you ever solve this issue? If so, what was the solution? – AdamT May 12 '15 at 08:28
  • @user2277872 How would one use the delegate methods to remove the AdBannerView? None of the delegate methods indicate when the current view changes. – AdamT May 12 '15 at 08:31

0 Answers0