在不触发警告的情况下以动画方式进出 iAd
我正在为屏幕底部的 iAd 横幅设置动画(0.5 秒),然后在完成后将其从超级视图中删除。
只要我有动画,iAd 阻塞收入就会出现在控制台中:
ADBannerView:警告横幅视图有广告,但可能会被遮挡。 此消息仅在每个横幅视图中打印一次。
代码很简单:(动画块中的行是问题)
[UIView animateWithDuration:0.5 animations:^{
self.adBannerView.frame = CGRectSetY(self.adBannerView.frame, viewHeight);
} completion:^(BOOL finished) {
[self.adBannerView removeFromSuperview];
}];
如果我只是忽略该消息,它会影响广告数量或我的应用程序收到的任何内容吗?
当我从 -(void)bannerViewDidLoadAd:(ADBannerView *)banner
委托方法对广告的外观进行动画处理时,也会发生这种情况,我只能使用will
该方法的变体。
如何在屏幕上和屏幕外制作 iAd 动画?
I am animating (for 0.5 seconds) an iAd banner off the bottom of the screen and then on completion removeing it from it's superview.
As long as I have the animation the iAd obstruction earning comes up in the console:
ADBannerView: WARNING A banner view has an ad but may be obscured.
This message is only printed once per banner view.
The code is simply: (the line in the animations block being the problem)
[UIView animateWithDuration:0.5 animations:^{
self.adBannerView.frame = CGRectSetY(self.adBannerView.frame, viewHeight);
} completion:^(BOOL finished) {
[self.adBannerView removeFromSuperview];
}];
If I just ignore the message will it affect the number of ads or anything that my app recieves?
This also happened when I was animating the appearance of an ad from the -(void)bannerViewDidLoadAd:(ADBannerView *)banner
delegate method, I could only stop the warnign from showing while keeping the animation by using the will
variation of that method.
How is animating iAds on and off screen meant to be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有一段时间也想知道同样的事情。我相信我已经想出了一个技巧,因为当我这样做时我没有收到任何警告。
这是我的视图层次结构:
下面的代码操作我在 Interface Builder 中设置的自动布局约束。如果您不使用自动布局,则必须更改触发动画的内容。
隐藏代码将 AD 横幅转换为“反向”视图。您可以使用 options 参数更改动画类型。
显示代码以另一种方式转换(从“反向”视图到 AD 横幅)。所有动画都发生在与 AD 横幅大小相同的超级视图中。这样你的整个视图就不会动画了。
将 iAd 保留在超级视图中,不要将其删除。这可能是警告的根本原因,但我不确定。
然后这是我的 AD 委托方法:
不要因为没有检查错误变量而杀了我。我还没有抽出时间来编写该代码。
关于在 iOS 6 自动布局中固定广告横幅视图的高度和宽度,如果在 iAd 动画回到原位时不这样做,左上角将向下和向右移动高度和宽度的一半每次返回视图时都会显示其超级视图。 :) 有趣的东西。
I was wondering the same thing for a while. I believe I've come up with a trick, because I don't get any warnings when I do this.
Here's the view hierarchy I have:
The code below manipulates the auto layout constraints I have setup in Interface Builder. If you're not using auto layout, then you'll have to change what triggers the animation.
The hide code transitions the AD Banner to the "reverse" view. You can change the animation types with the options parameter.
The show code transitions the other way (from "reverse" view to AD Banner). All of the animation happens with the superview which is the same size as the AD Banner. This way your entire view won't animate.
Leave the iAd in the superview, don't remove it. This may be the root cause of the warning, but I'm not sure.
Then here are my AD Delegate methods:
Don't kill me for not checking the error variable. I haven't gotten around to writing that code just yet.
With regard to pinning the height and width of the ad banner view in iOS 6 auto layout, if you don't when the iAd animates back into place, the upper left hand corner will shift down and to the right by half the height and width of its superview every time it comes back into view. :) Fun stuff.
该警告不会对您的应用程序造成任何不良影响。无论广告是否在屏幕上,广告都会加载,并且会调用委托方法。你做对了。该警告只是一个建议,因为有些人可能希望在某些视图大小调整等情况下显示广告,因此它只是建议广告应始终显示在屏幕上。但再次强调,这是一个建议,而不是一个错误。
The warning won't do anything bad to your app. Ads will load whether or not it's onscreen and delegate methods will be called. You're doing it correctly. The warning is just a suggestion because some people might want an ad to show up despite certain view resizes and such, so it just suggests that the ad should always be onscreen. But again, it's a suggestion, not an error.