当iAd无法填充时,如何将Admob广告整合到ios7应用中?

时间:2014-04-08 16:46:54

标签: ios7 xcode5 admob iad

我希望能够在iAds无法加载时在我的应用中显示AdMob广告,所以我们非常感谢您提供帮助。这是我的game.m(和view controller.m)中的iAds代码的副本

#pragma mark iAd Delegate Methods

-(void)bannerViewDidLoadAd:(ADBannerView *)banner{

    [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDuration:1];

    [banner setAlpha:1];

    [UIView commitAnimations];
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{

    [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDuration:1];

    [banner setAlpha:0];

    [UIView commitAnimations];

1 个答案:

答案 0 :(得分:0)

这是我的代码:

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
    [self addAdMob];
}

- (void) addAdMob {
    GADBannerView *adBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:CGPointMake(0, self.view.frame.size.height - 50)];
    adBanner.rootViewController = self;
    adBanner.delegate = self;
    adBanner.adUnitID = @"xxxxxxxxxxxxxxx";
    adBanner.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:adBanner];
    [adBanner loadRequest:[GADRequest request]];
}