【发布时间】:2010-12-30 03:59:18
【问题描述】:
我已经实现了 iAd 代码,但是无论是在模拟器上还是在我的设备上,它都喜欢在一段时间后让 iAd 消失,即使在互联网连接良好的情况下也是如此。我的实现是否有问题,或者这只是预期的?下面是代码和显示两者被调用频率的控制台。谢谢!
- (void)viewDidLoad {
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, 435); //orginally -50
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[self.view addSubview:adView];
adView.delegate = self;
self.bannerIsVisible = NO;
[super viewDidLoad];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
NSLog(@"bannerViewDidLoadAd");
if (!self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOn" context:NULL];
// banner is invisible now and moved out of the screen on 50 px
banner.frame = CGRectOffset(banner.frame, 0, -25); //orginally 50
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
NSLog(@"bannerViewRecievedError");
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// banner is visible and we move it out of the screen, due to connection issue
banner.frame = CGRectOffset(banner.frame, 0, 25); //orginally -50
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
- (void)dealloc {
NSLog(@"dealloc");
adView.delegate=nil;
[adView release];
[super dealloc];
}
控制台是这样说的:
2010-12-29 20:04:17.717 app[48943:207] bannerViewRecievedError
2010-12-29 20:04:52.410 app[48943:207] bannerViewRecievedError
2010-12-29 20:05:17.168 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:05:47.166 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:06:16.993 app[48943:207] bannerViewRecievedError
2010-12-29 20:06:46.803 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:07:17.314 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:07:47.140 app[48943:207] bannerViewRecievedError
2010-12-29 20:08:19.899 app[48943:207] bannerViewRecievedError
2010-12-29 20:08:46.978 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:09:17.106 app[48943:207] bannerViewRecievedError
2010-12-29 20:09:46.930 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:10:17.114 app[48943:207] bannerViewDidLoadAd
2010-12-29 20:10:47.609 app[48943:207] bannerViewDidLoadAd
【问题讨论】:
标签: iphone objective-c iad