-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[iAdbanner setAlpha:1];
[UIView commitAnimations];
[self.iAdbanner setDelegate:self];
_bannerView.hidden=YES;
_bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[iAdbanner setAlpha:0];
[UIView commitAnimations];
_bannerView.hidden=NO;
NSLog(@"iAd fails");
_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];
GADRequest *request =[GADRequest request];
request.testDevices= @[ GAD_SIMULATOR_ID ];
[self.bannerView loadRequest:request];
}
我将上面的代码放在ViewController1.m中,并且始终只有AdMob测试横幅加载。然后我将相同的代码放在View Controller2.m和ONLY iAd测试横幅加载,而不是AdMob。为什么会这样?代码错了吗?我处理调解错了吗?
我认为CPM iAd比AdMob更重要。 NSLog语句“iAd failed”从未出现过。