ADBannerView错误(没有委托或委托未实现didFailToReceiveAdWithError :) [英] ADBannerView error (no delegate or delegate does not implement didFailToReceiveAdWithError:)

查看:135
本文介绍了ADBannerView错误(没有委托或委托未实现didFailToReceiveAdWithError :)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在App Store上,并且没有显示任何广告.因此,在与Apple联系并没有收到任何解决方案之后,在模拟器上运行我的应用程序时,我在控制台中看到此错误:

My app is on the App Store and it doesn't show any ad. So, after contacting Apple and receiving no solution, I saw this error in the console while running my app on the simulator:

[AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=1 "Service session terminated." UserInfo=0x7f18e160 {ADInternalErrorCode=1002, NSLocalizedDescription=Service session terminated.}

这是我的应用程序不显示任何广告而仅在ADBannerView所在的空白处显示的原因吗?

Is that the reason why my app doesn't show any ads and just shows a white space where the ADBannerView is?

推荐答案

听起来像没有包含ADBannerView的委托方法.我已评论您的代码中可能缺少的部分.

Sounds like you haven't included the ADBannerView's delegate methods. I've commented the parts you may be missing from your code.

#import <iAd/iAd.h>

@interface ViewController () <ADBannerViewDelegate> // Have you included this?

@end

@implementation ViewController {
    // Your iAd Banner
    ADBannerView *iAdView;
}

-(void)viewDidLoad {
    [super viewDidLoad];

    // Setup iAd view
    iAdView = [[ADBannerView alloc] initWithFrame:CGRectZero];

    iAdView.delegate = self; // And have you done this?

    [iAdView setFrame:CGRectMake(0, 0, iAdView.bounds.size.width, iAdView.bounds.size.height)];
    iAdView.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height - (iAdView.bounds.size.height / 2));
    [self.view addSubview:iAdView];
    iAdView.alpha = 0.0;
}

// And have you included these delegate methods to handle when an ad is received or not?
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
    NSLog(@"iAd received ad");
    // display ad
    iAdView.alpha = 1.0;
}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
    NSLog(@"iAd failed");
    // Hide ad
    iAdView.alpha = 0.0;
}

这篇关于ADBannerView错误(没有委托或委托未实现didFailToReceiveAdWithError :)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆