xcode iAd“没有委托或委托没有实现 didFailToReceiveAdWithError:”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11705090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iAd "no delegate or delegate does not implement didFailToReceiveAdWithError:"
提问by matt saravitz
I ran my app with wifi disabled and I always get white space and this message in the debugger:
我在禁用 wifi 的情况下运行我的应用程序,我总是在调试器中看到空白和此消息:
ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=5 "The operation couldn't be completed. Banner view is visible but does not have content" UserInfo=0x9632d30 {ADInternalErrorCode=5, NSLocalizedFailureReason=Banner view is visible but does not have content}
ADBannerView:未处理的错误(没有委托或委托未实现 didFailToReceiveAdWithError :):错误域=ADErrorDomain Code=5“操作无法完成。横幅视图可见但没有内容” UserInfo=0x9632d30 {ADInternalErrorCode=5, NSLocalizedFailureReason=横幅视图可见但没有内容}
Please help me fix my code: .h
请帮我修复我的代码:.h
#import <iAd/iAd.h>
@interface ViewController : UIViewController <GKAchievementViewControllerDelegate, GameCenterManagerDelegate , ADBannerViewDelegate> {
//iAD
ADBannerView *banner;
}
//iAD
@property (nonatomic, assign) BOOL bannerIsVisible;
@property (nonatomic, retain) IBOutlet ADBannerView *banner;
.m
.m
@synthesize banner , bannerIsVisible;
-(void)bannerViewDidLoadAd:(ADBannerView *)abanner {
if (!self.bannerIsVisible) {
[UIView beginAnimations:@"animatedAdBannerOn" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0.0, 50.0);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}}
-(void)bannerView:(ADBannerView *)aBanner didFailToReceiveAdWithError:(NSError *)error {
if (!self.bannerIsVisible) {
[UIView beginAnimations:@"animatedAdBannerOff" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0.0, -50.0);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
回答by Stunner
As per the delegate portion of the error. In your viewDidLoad (or wherever you initialize) method set banner.delegate = self;
根据错误的委托部分。在您的 viewDidLoad(或您初始化的任何地方)方法集banner.delegate = self;
回答by Joel West
Completely new to iOS development, but I believe you need to set the adBanner view delegate in the storyboard. To do this right click the adBanner and drag to files owner. Then select delegate. This solved this issue for me :).
全新的 iOS 开发,但我相信您需要在故事板中设置 adBanner 视图委托。为此,右键单击 adBanner 并拖动到文件所有者。然后选择委托。这为我解决了这个问题:)。
回答by Robert Wohnoutka
You may need to set the delegate in interface Builder (IB). Otherwise when the view loads there is no delegate assigned and you will get this error message.
您可能需要在界面生成器 (IB) 中设置委托。否则,当视图加载时没有分配委托,您将收到此错误消息。