在模拟器和设备上运行时,控制台会显示didFailToReceiveAdWithError
消息。
iOS 8 上运行时,iAd横幅广告能够成功展示。但是在iOS 9上运行时,iAd横幅广告无法接收到广告。
.h
#import <iAd/iAd.h>
@interface ViewController : UIViewController <ADBannerViewDelegate>
@property (retain, nonatomic) IBOutlet ADBannerView *adBanner;
.m
(直接翻译为):这是一个带有强调的段落,其中包含“.m”。
-(void)viewDidLoad {
self.adBanner = [[ADBannerView alloc]initWithFrame:CGRectMake(0,[UIScreen mainScreen].bounds.size.height-100, [UIScreen mainScreen].bounds.size.width, 50)];
self.adBanner.delegate=self;
[self.adBanner setBackgroundColor:[UIColor clearColor]];
[self.view addSubview:self.adBanner];
}
-(void)bannerViewWillLoadAd:(ADBannerView *)banner {
NSLog(@"bannerViewWillLoadAd");
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
// Show the ad banner.
NSLog(@"bannerViewDidLoadAd");
[UIView animateWithDuration:0.5 animations:^{
self.adBanner.alpha = 1.0;
}];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
NSLog(@"didFailToReceiveAdWithError");
// Hide the ad banner.
[UIView animateWithDuration:0.5 animations:^{
self.adBanner.alpha = 0.0;
}];
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner {
NSLog(@"Ad did finish");
}
在运行 iOS 9 时,控制台会每次输出didFailToReceiveAdWithError
。