我实现了iAds在bannerViewDidLoadAd方法中工作,然后我实现了AdMob在didFailToReceiveAdWithError方法中工作。但是,在同一个视图控制器上,我有一个GameOver方法,我希望广告出现。只有iAd加载GameOver方法,AdMob没有。此外,当iAds加载失败时,AdMob无法加载。在我看来,因为我以编程方式将GADBannerView添加到故事板上,游戏永远不会响应_bannerView.hidden = YES或NO。由于我在Xcode中添加了来自Object Library的ADBannerView,因此游戏只响应iAdBanner.hidden = YES或NO。为什么AdMob不响应以编程方式添加的广告横幅?
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[iAdBanner setAlpha:1];
iAdBanner.hidden=NO;
[UIView commitAnimations];
[self.iAdBanner setDelegate:self];
_bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[iAdBanner setAlpha:0];
iAdBanner.hidden=YES;
[UIView commitAnimations];
_bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
_bannerView=[[GADBannerView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
self.bannerView.adUnitID=@"UNIT-ID";
self.bannerView.rootViewController=self;
[self.view addSubview:self.bannerView];
self.bannerView.delegate = self;
GADRequest *request =[GADRequest request];
request.testDevices= @[ GAD_SIMULATOR_ID ];
[self.bannerView loadRequest:request];
}