我隐藏了 AdBannerView 但仍然收到警告横幅视图 (0x9c75550) 有广告
我刚刚在我的应用程序中添加了 ADBannerview。我在 UIApplicationDelegate 中创建 AdBannerView 以便只拥有它的一个实例,并在不同的 viewController 中共享它
一切正常,除了收到警告消息: ADBannerView:警告横幅视图 (0x9c75550) 有广告,但可能会被遮挡。此消息仅在每个横幅视图中打印一次。
当我在当前显示 ADBannerview 的视图顶部打开模式视图(使用presentModalViewController)时。在打开模式视图之前,我使用以下代码来隐藏 ADBannerview:
- (void)viewWillDisappear:(BOOL)animated
{
ADBannerView *bannerView = [ (ScoreBoardAppDelegate*)[[UIApplication sharedApplication] delegate] adBanner];
[self hideBanner:bannerView];
[super viewWillDisappear:animated];
}
- (void)hideBanner:(ADBannerView*) adBanner {
NSLog(@"%s called", __FUNCTION__);
// Grow the tableview to occupy space left by banner, it's the size of the parent view
CGFloat fullViewHeight = self.tbView.frame.size.height;
CGRect tableFrame = self.tv.frame;
tableFrame.size.height = fullViewHeight;
// Move the banner view offscreen
CGRect bannerFrame = adBanner.frame;
CGRect screenBounds = [[UIScreen mainScreen] bounds];
bannerFrame.origin = CGPointMake(CGRectGetMinX(screenBounds), CGRectGetMaxY(screenBounds));
self.tv.frame = tableFrame;
adBanner.frame = bannerFrame;
}
我不明白该怎么做才能不出现此警告消息。在显示模态视图之前,ADBannerView 似乎已成功隐藏(屏幕外)。
我可能错过了一些东西,但我看不到它。 感谢您的帮助,
塞巴斯蒂安。
I have just added an ADBannerview in my App. I create the AdBannerView in my UIApplicationDelegate in order to have only one instance of it and I share it in the different viewController
Everything works perfectly except I get the warning message: ADBannerView: WARNING A banner view (0x9c75550) has an ad but may be obscured. This message is only printed once per banner view.
when I open a modal view (using presentModalViewController) on top of the view that is currently displaying the ADBannerview. Before opening the modal view I'm using the following code to hide the ADBannerview:
- (void)viewWillDisappear:(BOOL)animated
{
ADBannerView *bannerView = [ (ScoreBoardAppDelegate*)[[UIApplication sharedApplication] delegate] adBanner];
[self hideBanner:bannerView];
[super viewWillDisappear:animated];
}
- (void)hideBanner:(ADBannerView*) adBanner {
NSLog(@"%s called", __FUNCTION__);
// Grow the tableview to occupy space left by banner, it's the size of the parent view
CGFloat fullViewHeight = self.tbView.frame.size.height;
CGRect tableFrame = self.tv.frame;
tableFrame.size.height = fullViewHeight;
// Move the banner view offscreen
CGRect bannerFrame = adBanner.frame;
CGRect screenBounds = [[UIScreen mainScreen] bounds];
bannerFrame.origin = CGPointMake(CGRectGetMinX(screenBounds), CGRectGetMaxY(screenBounds));
self.tv.frame = tableFrame;
adBanner.frame = bannerFrame;
}
I don't understand what to do to not have this warning message. It seems the ADBannerView is successfully hidden (offscreen) before the Modal view is displayed.
I probably missed something but I cannot see it.
Thanks for your help,
Sébastien.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
塞巴斯蒂安,我希望你已经不再讨论这个问题了,因为这个问题已经好几个月没有得到解答了。我最近添加了 iAd 支持,发现这个警告也很烦人。共享广告横幅的微妙之处之一是,如果您想在初始视图控制器中显示它,则必须在该视图控制器中完成大部分设置,而不是在应用程序委托中。
这是我的初始视图控制器中的 viewWillAppear: 方法:
SharedAdBannerView 是 TN2286 中定义的宏,它利用应用程序委托上定义的实例变量(这就是它在显示 iAd 的所有视图之间保持共享的方式)。我还决定在将广告横幅从视图层次结构中删除之前先将广告横幅动画化,然后将其从视图层次结构中删除,因为一个场景正在延续到另一个场景。我读到的文档说,只要广告横幅是视图层次结构的一部分,您就会收到该消息 - 换句话说,隐藏横幅视图并不是阻止警告消息的方法。或者换句话说,如果隐藏广告横幅就足够了,那么它对我来说不起作用,并且对故障排除没有帮助。当我遇到 TN2239 时,我学到了很多,它在 gdb 中提供了此提示:
您必须根据放置断点的位置来调整向其发送 recursiveDescription 消息的对象,但可能 [self view] 没问题。
Sébastien, I hope you've moved on from this since the question has gone unanswered for so many months. I recently added iAd support and found this warning to be quite annoying too. One of the subtleties of sharing an ad banner is that if you want to show it in your initial view controller, you have to do most of the setup in that view controller, not in the app delegate.
This is the viewWillAppear: method in my initial view controller:
SharedAdBannerView is a macro as defined in the TN2286, and it is utilizing an instance variable defined on the app delegate (which is how it remains shared amongst all views that display an iAd). I also decided to animate the ad banner off the screen before removing it from the view hierarchy as one scene was segueing to another scene. I read the documentation as saying that whenever an ad banner is a part of a view hierarchy you would get that message -- in other words, hiding the banner view isn't the way to prevent the warning message. Or put differently, if it is sufficient to hide the ad banner, it didn't work for me and it didn't help in troubleshooting. I learned a lot when I came across TN2239 which offered this tip in gdb:
You have to adjust the object to whom you send the recursiveDescription message based on where you placed your breakpoint, but probably [self view] is fine.