ARC で Xcode 4.5 を使用していますが、iAd を使用して次のメッセージが表示されます。
警告: 現在、ADBannerView または ADInterstitialView のインスタンスが 10 を超えています。これは iAd API の誤用であり、結果として広告のパフォーマンスが低下します。
私はこの投稿を読みました: Iad WARNING: More than 10 instances of ADBannerView but that code is without ARC it, it look, which I have.
私のコード:
-(AppDelegate *) appdelegate {
return (AppDelegate *) [[UIApplication sharedApplication]delegate];
}
-(void) viewWillAppear:(BOOL)animated {
_UIiAD = [[self appdelegate]UIiAD];
_UIiAD.delegate = self;
adView = [[ADBannerView alloc]initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, 460.0);
adView.requiredContentSizeIdentifiers = [NSSet setWithObject: ADBannerContentSizeIdentifierPortrait];
[self.view addSubview:adView];
adView.delegate = self;
self.bannerIsVisible = NO;
}
- (void) viewWillDisappear:(BOOL)animated {
_UIiAD.delegate = nil;
_UIiAD = nil;
[_UIiAD removeFromSuperview];
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
if(!self.bannerIsVisible) {
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
//banner is invisible now and moved out of the screen
banner.frame = CGRectMake(0.0, 5.0, banner.frame.size.width, banner.frame.size.width);
[UIView commitAnimation];
self.bannerIsVisible = YES;
NSLog(@"bannerViewDidLoadAd is working!");
}
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if (self.bannerIsVisible) {
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
//banner is visible and we move it out of the screen due to connection issues
banner.frame = CGRectMake(0.0, -50.0, banner.frame.size.width, banner.frame.size.width);
// [UIView commitAnimation];
self.bannerIsVisible = NO;
NSLog(@"didFailtoReceiveWithError is working");
}
}
-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave {
NSLog(@"Banner view is beginning an ad action");
BOOL shouldExecuteAction = YES;
if (willLeave && shouldExecuteAction) {
// stop all interaction process in the app. Use this to stop sounds or video so the ad can display properly
// [video pause];
// [sound pause];
}
return shouldExecuteAction;
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner {
// resume everything you've stopped
// [video resume];
// [audio resume];
}