iAd 无法正常工作
大家好,我通过以下提到的链接的帮助编写了这段代码
问题是:在输出中,只有视图在模拟器中可见,没有其他内容。
http://www.youtube.com/watch?v=VsNGDuJ6-Fs
.h 代码中的代码如下
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface RootViewController : UIViewController<ADBannerViewDelegate>{
IBOutlet ADBannerView *aBanner;
}
@property (nonatomic, retain) ADBannerView *aBanner;
@property (nonatomic, assign) BOOL bannerIsVisible;
@end
.m 文件中的
#import "RootViewController.h"
@implementation RootViewController
@synthesize aBanner,bannerIsVisible;
#pragma mark ADBannerViewDelegate
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
if (!self.bannerIsVisible){
[UIView beginAnimations:@"animationAdBannerOn" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
if (self.bannerIsVisible){
[UIView beginAnimations:@"animationAdBannerOff" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
,并将 Ad BannerView 正确链接到 aBanner,在 .xib 文件中
我不知道我缺少哪里,请帮助我朋友
获取此日志
iAdDemo[1696:207] ADBannerView:未处理的错误(没有委托或委托未实现 didFailToReceiveAdWithError:):错误 Domain=ADErrorDomain Code=5 “操作无法完成。横幅视图可见,但没有内容" UserInfo=0x57180e0 {ADInternalErrorCode=5, NSLocalizedFailureReason=横幅视图可见,但没有内容}
Hi All I have written this code by taking help with this below mention link
Problem is: on out put only view is visible in the simulator nothing else.
http://www.youtube.com/watch?v=VsNGDuJ6-Fs
Code is as follows in .h
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface RootViewController : UIViewController<ADBannerViewDelegate>{
IBOutlet ADBannerView *aBanner;
}
@property (nonatomic, retain) ADBannerView *aBanner;
@property (nonatomic, assign) BOOL bannerIsVisible;
@end
code in .m file
#import "RootViewController.h"
@implementation RootViewController
@synthesize aBanner,bannerIsVisible;
#pragma mark ADBannerViewDelegate
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
if (!self.bannerIsVisible){
[UIView beginAnimations:@"animationAdBannerOn" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, -banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
if (self.bannerIsVisible){
[UIView beginAnimations:@"animationAdBannerOff" context:NULL];
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
and properly link the Ad BannerView to aBanner, in .xib file
i don't know where i am lacking please help me out Friends
Getting this log
iAdDemo[1696: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=0x57180e0 {ADInternalErrorCode=5, NSLocalizedFailureReason=Banner view is visible but does not have content}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否为 Adview 设置了委托。
在你看来DidLoad
只是一个提示。有效地处理您的 Adview。
在你的 Dealloc 中使用这个
Have you set the delegate for the Adview.
In your viewDidLoad
Just a hint. Handle your Adview efficiently.
In your Dealloc use this