2013-10-30 41 views
0

我已将iAd放入我的应用程序,并且由于某种原因,当我在模拟器中运行它时,它会导致错误。iAd有时不工作

ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=0 "The operation couldn’t be completed. Unknown error" UserInfo=0x9258b10 {ADInternalErrorCode=0, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Unknown error}

我有框架和做正确的头文件,但它确实显示广告,它有时会出现此错误

回答

0

你遇到这个错误的XCode无法找到您的附加在您的storyboard.xib文件。此外,你得到这个错误,因为你没有didFailToReciveAdWithError无效。你应该使用的代码如下。

你不需要在你的头文件做任何事,只是将下面的代码添加到您的.m文件:

-(void)bannerViewDidLoadAd:(ADBannerView *)banner { 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1]; 
    [banner setAlpha:1]; 
    [UIView commitAnimations]; 
} 

- (void)bannerView:(ADBannerView *) banner didFailToReceiveAdWithError:error{ 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1]; 
    [banner setAlpha:0]; 
    [UIView commitAnimations]; 
} 

再次,你不需要在你的头文件进行任何操作。接下来进入您的.xibstoryboard文件,并摆脱任何outlets,或任何其他连接到您的横幅视图。接下来,右击你banner views和出口delegate拖到file's owner

+0

对不起,如果我听起来noobish但是我不知道在哪里文件的所有者部分是,我知道一切,但该部分 – user2933653

+1

您是否使用了'的.xib '或'故事板'? @ user2933653如果您使用'storyboard',它实际上将在'storyboard'文件中称为您的'ViewController',或者任何您命名为'viewcontroller'的内容。 – Jojodmo

+0

你有想过吗? – Jojodmo