Objective c - Iad WARNING: More than 10 instances of ADBannerView

百般思念 提交于 2019-12-13 18:26:01

问题


i have developed a tab bar application. Like title i have an iad banner positioned at bottom of screen. I have implemented this method to create/destroy banner and test iad works correctly:

Create:

-(void)viewWillAppear:(BOOL)animated {
     if(!adView) {
        adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, 315, 310, 45)];
        adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
        adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
        adView.delegate = self;
        [self.view addSubview:adView];
    }

Destroy:

    - (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    // iAd
    if (adView != nil) {
        adView.delegate = nil;
        adView.hidden = YES;
        adView = nil;
       [adView release];
    }  
}

But if i try to rapid change view from tab bar i receive this 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.

But the method create and destroy are always called. What i can do to debug this warning problem? Thanks so much.


回答1:


You need to release your instance variable before you nil it, not the other way around.

adView = nil;
[adView release];

Should be:

[adView release];
adView = nil;


来源:https://stackoverflow.com/questions/12669989/objective-c-iad-warning-more-than-10-instances-of-adbannerview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!