这是在iAd不可用时补充AdMob的正确方法吗?

  • 本文关键字:AdMob 方法 iAd ios admob iad
  • 更新时间 :
  • 英文 :

我想

在iAd不可用时用AdMob广告填充iAd空间,并且想知道这是否是编码的正确方法。每次我运行模拟器时,它都会显示 iAd,当它没有时,它会显示一条白色条带,所以我想知道我是否编码错误。有人可以帮助我,并在必要时修复代码,或添加建议。谢谢。

//iAd Advertising
#pragma mark iAd Delegate Methods
- (void) bannerViewDidLoadAd:(ADBannerView *)banner {
    advertisement.hidden = NO;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [banner setAlpha:1];
    [UIView commitAnimations];
    //bannerView_.hidden = YES;
} // if there is an internet connection, load the iAd with a 1 second fade in effect
- (void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [banner setAlpha:1];
    [UIView commitAnimations];
    advertisement.hidden = YES;

    bannerView_.hidden = NO;
    bannerView_ = [[GADBannerView alloc]initWithFrame:CGRectMake(0, 20, 320, 50)];
    bannerView_.adUnitID = @"//pubname";
    bannerView_.rootViewController = self;
    [self.view addSubview:bannerView_];
    [bannerView_ loadRequest:[GADRequest request]];
}
@end

你的代码是对的。我猜错误出在故事板中。在情节提要上,单击 iAd 并确保 Alpha 设置为 0。这应该可以解决它。

抱歉回答晚了。

相关内容

最新更新