iAds:bannerViewDidLoadAd 在第一次 didFailToReceiveAdWithError 之后不再调用
我正在 XCode 4 中测试 iAds。
一切正常,直到第一次收到 bannerView:didFailToReceiveAdWithError:
为止,我通过将横幅滑出屏幕来做出反应。
//move the ad back off the screen if an error occurs
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if (self.bannerIsInScreenBounds)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// move the banner view off the screen.
banner.frame = CGRectOffset(banner.frame, 320, 0);
[UIView commitAnimations];
}
}
此后,不再向 ADBannerViewDelegate 发送 bannerViewDidLoadAd:
消息。我将该方法记录在顶部,不再被调用。
我不会发布横幅或任何内容,并且 ADBannerViewDelegate 类仍然存在并执行其他操作。
可能出什么问题了?
谢谢。
I'm testing iAds in XCode 4.
Everything works fine, until the first time a bannerView:didFailToReceiveAdWithError:
is received, which I react to by sliding the banner off the screen.
//move the ad back off the screen if an error occurs
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
if (self.bannerIsInScreenBounds)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// move the banner view off the screen.
banner.frame = CGRectOffset(banner.frame, 320, 0);
[UIView commitAnimations];
}
}
After that, no more bannerViewDidLoadAd:
messages are sent to the ADBannerViewDelegate. I'm logging that method right at the top, it's not being called any more.
I'm not releasing the banner or anything, and the ADBannerViewDelegate class is still there and doing other stuff.
What could be wrong?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为什么你期望它在发生错误后加载广告 - 我认为这是正确的行为。
查看评论,它显示错误是“操作无法完成。广告库存不可用”。
如果它找不到任何可提供的广告,您如何期望它向您提供广告;)
Why do you expect it load adverts after an error has happened - I think this is the correct behavior.
Looking at the comments it show that the error is "The operation couldn’t be completed. Ad inventory unavailable".
How do you expect it to give you adverts if it can't find any adverts to give ;)
好吧,这不是一个理想的解决方案,但这就是我最终所做的。
每当我收到 didFailToReceiveAdWithError 错误时,我都会等待 10 秒(以避免因失败而发送垃圾邮件),然后重新创建横幅。
OK, not an ideal solution but here's what I ended up doing.
Whenever I get a didFailToReceiveAdWithError, I wait 10 seconds (to avoid spamming with failures) then recreate the banner.
正如我在 如何实现 AdBannerview 和 ADBannerview delegate 中的评论,运行 iphone在 ipad 模拟器中的应用程序中,我在设置 ADBannerView 委托时立即得到
didFailToReceiveAdWithError
,并且再也没有另一个委托调用。在 iPhone 模拟器上运行它(或将应用程序目标更改为通用),仅在将 ADBannerView 添加为子视图后才调用委托,然后每 30 秒委托一次调用。As my comment at how to implement AdBannerview and ADBannerview delegate, running iphone app in ipad simulator I got
didFailToReceiveAdWithError
immediately on setting the ADBannerView delegate, and never another delegate call. Running it on the iphone simulator (or changing the app target to universal) the delegate only got called after adding ADBannerView as a subview, and then delegate calls every 30 secs after that.