我在 iphone 应用程序中插入了 adBannerView。我遵循文档中描述的苹果示例。当应用程序在调试模式下运行时,广告会正确显示(测试版),但在发布版中,当真实用户使用应用程序时,我会看到一个白框,应该在其中显示横幅。
也许我错过/忘记了某些事情或者我做错了什么?
显示横幅的视图控制器有一个 initBanner 方法:
- (void) initBanner{
ADBannerView *_bannerView = nil;
if (!is2ShowBanner){
_bannerView = nil;
MyLogEvidence(@"%@ BANNER da Nascondere", [self.class description]);
return;
}
MyLogEvidence(@"%@ BANNER da Visualizzare", [self.class description]);
_bannerView = [[ADBannerView alloc] initWithAdType:ADAdTypeBanner];
[_bannerView setDelegate:self];
CGRect bounds = self.view.bounds ;
CGRect frame = _bannerView.frame;
frame.origin = CGPointMake(CGRectGetMinX(bounds),CGRectGetMaxY(bounds)- _bannerView.frame.size.height);
[_bannerView setFrame:frame];
[self.view addSubview:_bannerView];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
[self layoutForBanner:banner animated:YES ];
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
[self layoutForBanner:banner animated:YES];
}
- (void)layoutForBanner:(ADBannerView*)_bannerView animated:(BOOL)animated
{
if (_bannerView == nil){
MyLog(@"BANNER non presente");
[_constraintVerticalForBanner setConstant:3.0];
[self.view layoutIfNeeded];
[self.view updateConstraintsIfNeeded];
return;
}
[_bannerView setHidden:!_bannerView.bannerLoaded];
[_constraintVerticalForBanner setConstant:_bannerView.hidden? 3.0 : _bannerView.frame.size.height+3];
[self.view layoutIfNeeded];
[self.view updateConstraintsIfNeeded];
MyLog(@"%@.constraintVerticalForBanner start: %3.0f",[self.class description],_constraintVerticalForBanner.constant);
}
-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave{
return YES;
}
通话开始于:
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[self initBanner];
}