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

时间:2014-02-27 17:40:27

标签: 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

1 个答案:

答案 0 :(得分:0)

你的代码是对的。我猜错误是在故事板中。在故事板上单击iAd并确保Alpha设置为0.这应该解决它。

对不起,迟到了。