我在我的视图类中实现了以下代码(也使视图符合ADBannerVIEwDelegate协议):
//add iAdsADBannerVIEw *adVIEw = [[ADBannerVIEw alloc] initWithFrame: CGRectMake(0,318,320,50)];adVIEw.requiredContentSizeIDentifIErs = [NSSet setWithObjects: ADBannerContentSizeIDentifIErPortrait,ADBannerContentSizeIDentifIErLandscape,nil];adVIEw.delegate = self; //adVIEw.delegate = ADBannerVIEwDelegate;[self.vIEw addSubvIEw: adVIEw];
然后我为ADBannerVIEwDelegate创建了一个类,其中包含以下.m
//// ADBannerVIEwDelegate.m//#import "ADBannerVIEwDelegate.h"@implementation ADBannerVIEwDelegate- (voID)bannerVIEw:(ADBannerVIEw *)banner dIDFailToReceiveADWithError:(NSError *)error{ NSLog(@"bannervIEw dID not receive any banner due to %@",error);}- (voID)bannerVIEwActionDIDFinish:(ADBannerVIEw *)banner{NSLog(@"bannervIEw was selected");}- (BOol)bannerVIEwActionShouldBegin:(ADBannerVIEw *)banner willLeaveApplication:(BOol)willLeave{return willLeave;}- (voID)bannerVIEwDIDLoadAd:(ADBannerVIEw *)banner {NSLog(@"banner was loaded");}@end
最终会显示横幅,但控制台会继续抛出以下类型的错误:
2011-02-27 15:00:54.108 app[31639:207] 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=0x6356a40 {ADInternalErrorCode=5,NSLocalizedFailureReason=banner view is visible but does not have content}
并且委托函数没有做任何事情,所以根本没有NSLog.显然没有抓住错误.
我很难过.我想我在视图和委托中的Adbanner视图调用的链接中遗漏了一些东西.不知道该怎么做或出了什么问题.
有帮助吗?提前致谢.
贾森
解决方法 你之所以告诉AdBannerVIEw你是它的委托,但你从来没有把它放在你的实现文件中.您的实现文件应如下所示(注意@implmentation的行)://// ADBannerVIEwDelegate.m//#import "ADBannerVIEwDelegate.h"@implementation ADBannerVIEwDelegate<ADBannerVIEwDelegate>- (voID)bannerVIEw:(ADBannerVIEw *)banner dIDFailToReceiveADWithError:(NSError *)error{ NSLog(@"bannervIEw dID not receive any banner due to %@",error);}- (voID)bannerVIEwActionDIDFinish:(ADBannerVIEw *)banner{NSLog(@"bannervIEw was selected");}- (BOol)bannerVIEwActionShouldBegin:(ADBannerVIEw *)banner willLeaveApplication:(BOol)willLeave{return willLeave;}- (voID)bannerVIEwDIDLoadAd:(ADBannerVIEw *)banner {NSLog(@"banner was loaded");}@end
而且你也不应该把你的班级命名为ADBannerVIEwDelegate.您的类应该是ADBannerVIEw的委托(响应它),但不能以它的名字命名.
总结以上是内存溢出为你收集整理的iphone – 如何实现AdBannerview和ADBannerview委托全部内容,希望文章能够帮你解决iphone – 如何实现AdBannerview和ADBannerview委托所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)