当前位置:  开发笔记 > IOS > 正文

iAd横幅无法在iOS 9上运行

如何解决《iAd横幅无法在iOS9上运行》经验,为你挑选了1个好方法。

didFailToReceiveAdWithError在模拟器和设备上运行时在控制台中收到消息.

在iOS 8上运行时,iAd横幅会成功显示.在iOS 9上运行时,iAd横幅无法接收广告.

.H

#import 
@interface ViewController : UIViewController 

@property (retain, nonatomic) IBOutlet ADBannerView *adBanner;

.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每次都会打印.



1> Daniel Storm..:

我无法重新创建您的问题.在测试时,您的国家/地区的iAd网络可能已关闭,您可能位于iAd不支持的国家/地区,或者您可能在开发设备/模拟器上将iAd测试填充率设置为0%.转到设置>开发人员>填充率>,然后检查开发设备/模拟器上的填充率是否设置为100%.

我建议打印error你正在接收的内容,didFailToReceiveAdWithError这样你就可以找出ADBannerView失败的原因.

-(void)viewDidLoad {
    // The ADBannerView will size itself based on the device it is being displayed on
    // Only setting the position is sufficient
    self.adBanner = [[ADBannerView alloc]initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height-100, 0, 0)];
    self.adBanner.delegate=self;
    // Removed setBackgroundColor
    // Set alpha to 0.0 initially
    self.adBanner.alpha = 0.0;
    [self.view addSubview:self.adBanner];
}

-(void)bannerViewWillLoadAd:(ADBannerView *)banner {
    NSLog(@"bannerViewWillLoadAd");
}

-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
    NSLog(@"bannerViewDidLoadAd");
    [UIView animateWithDuration:0.5 animations:^{
        self.adBanner.alpha = 1.0;
    }];
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
    // Changed NSLog to print the error that is received
    NSLog(@"didFailToReceiveAdWithError: %@", error);
    [UIView animateWithDuration:0.5 animations:^{
        self.adBanner.alpha = 0.0;
    }];
}

-(void)bannerViewActionDidFinish:(ADBannerView *)banner{
    NSLog(@"bannerViewActionDidFinish");
}

如果您仍然遇到此问题,您应该直接联系iAd并根据他们的回复更新您的问题,或者如果他们能够为您解决问题,请回复.

推荐阅读
手机用户2402852307
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有