简体   繁体   English

当iAd可能被遮挡时,这是一个问题吗?

[英]Is it a problem when an iAd may be obscured?

I added the ADBannerView to a view and when I load the app I get the following message: 我将ADBannerView添加到视图中,当我加载应用程序时,我收到以下消息:

ADBannerView: WARNING A banner view (0x7a023c0) has an ad but may be obscured. ADBannerView:警告横幅视图(0x7a023c0)有广告但可能会被遮挡。 This message is only printed once per banner view. 此消息仅在每个横幅视图中打印一次。

As far as I can see the entire banner is visible on the screen. 据我所知,整个横幅在屏幕上可见。 Is this really a problem? 这真的是个问题吗? Or is it only a warning that I can ignore? 或者这只是一个我可以忽略的警告?

As Stephen Darlington says, it's a good idea to figure out what the issue is. 正如斯蒂芬达林顿所说,找出问题是个好主意。 An easy way to double-check this in code (from a view controller) would be: 在代码中(从视图控制器)仔细检查这个的简单方法是:

     // bring your bannerView to the front
   [self.view bringSubviewToFront:bannerView];

     // and make sure it's positioned onscreen.
    bannerView.frame = CGRectMake(0.0, 0.0, bannerView.frame.size.width, bannerView.frame.size.height);

Assuming you had an iVar / IBOutlet to your AdBannerView called bannerView, this would take care of any interface builder positioning issues, and make sure bannerView wasn't covered by anything. 假设您有一个名为bannerView的AdBannerView的iVar / IBOutlet,这将解决任何界面构建器定位问题,并确保bannerView未被任何内容覆盖。

From my experience, nothing bad happens if the ad is offscreen, however, the iAd will not load new ads until it knows it is fully onscreen. 根据我的经验,如果广告在屏幕外,则不会发生任何不良事件,但是,iAd不会加载新广告,直到它知道它完全在屏幕上。 So, as you start up your app, 所以,当你启动你的应用程序时,

  1. Your AdBannerView will attempt to load an advertisement, whether it is onscreen or not. 您的AdBannerView将尝试加载广告,无论是否在屏幕上。

  2. Depending on whether or not it is successful, your AdBannerViewDelegate will receive either 根据是否成功,您的AdBannerViewDelegate将收到

    a) bannerViewDidLoadAd: (proceed to step 3) or a)bannerViewDidLoadAd :(继续步骤3)或

    b) bannerView: didFailToReceiveAdWithError: (the AdBannerView will try again on its own) b)bannerView:didFailToReceiveAdWithError :( AdBannerView将自行重试)

  3. At that point, the ball is in your court as to what to do with said bannerView, if in fact it did load an ad. 那时候,球在你的球场上是关于如何处理所述bannerView,如果事实上它确实加载了一个广告。 An easy way to check for this in code is yourBannerView.bannerLoaded, which will return YES if it has an ad, or NO if it doesn't. 在代码中检查这一点的简单方法是yourBannerView.bannerLoaded,如果有广告则返回YES,否则返回NO。 And so... 所以...

  4. How you handle the AdBannerView after it successfully loads its initial ad determines how it will behave in the future. 在成功加载其初始广告后,如何处理AdBannerView将决定它在未来的行为方式。 You do not have to place it onscreen immediately -- choose a time that makes sense within your application. 您不必立即将其放在屏幕上 - 选择在您的应用程序中有意义的时间。 However, a banner view that has successfully loaded an ad will NOT try to load another one until it is onscreen. 但是,已成功加载广告的横幅视图不会尝试加载另一个广告,直到它在屏幕上。 (Makes sense, right?) The tricky part is.... (有道理,对吗?)棘手的部分是....

    4b) you also won't get any new delegate messages from that bannerView, so if you're not moving the bannerView onscreen immediately upon getting the bannerViewDidLoadAd delegate message, you'll have to implement some kind of control structure on your own to handle when, if at all, you DO move it onscreen, at which point it will begin asking the ad server for more ads, and you'll get more delegate messages, and the cycle begins anew. 4b)你也不会从该bannerView获得任何新的委托消息,所以如果你在获得bannerViewDidLoadAd委托消息时没有立即在屏幕上移动bannerView,你必须自己实现某种控制结构来处理什么时候,如果有的话,你可以在屏幕上移动它,此时它将开始向广告服务器询问更多广告,并且您将获得更多的委托消息,并且周期重新开始。

So, to sum up: It's only a problem if your iAd is obscured if you'd like to serve more iAds and get paid. 总而言之:如果您希望提供更多iAd并获得报酬,那么如果您的iAd被遮挡,那么这只是一个问题。 However, eCPM has been very, very low lately, so maybe that's not such an issue after all ;) 然而,最近eCPM一直非常非常低,所以也许这毕竟不是一个问题;)

To add to this discussion, I received this message when I modified the center property to move the ad just outside the screen. 为了添加到此讨论中,我在修改center属性以在屏幕外移动广告时收到此消息。 I use UIView animations to slide the ad onto the screen. 我使用UIView动画将广告滑动到屏幕上。

After some experimenting I figured out how to do this without causing the message to appear. 经过一些实验后,我想出了如何在不导致消息出现的情况下执行此操作。 The trick was to hide to set the adBannerView.hidden property to YES while waiting for the ad to load. 诀窍是隐藏以在等待广告加载时将adBannerView.hidden属性设置为YES。 Once it was loaded, I just had to make sure to set the hidden property to NO only after committing the animation: 一旦加载,我只需要确保提交动画后将隐藏属性设置为NO:

-(void) fadeAdIn:(UIView*)view
{
    float offsetY = view.frame.size.height * (bannerOnBottom ? 1 : -1);

    CGPoint pos = [self getBannerPosition];
    view.center = CGPointMake(pos.x, pos.y + offsetY);

    [UIView beginAnimations:@"AdIn" context:nil];
    [UIView setAnimationDuration:1.0];
    view.center = pos;
    [UIView commitAnimations];

    // must unhide AFTER animation has been committed to prevent "ad obstructed"
    view.hidden = NO;
}

Like compiler warnings, I think this is something that you should probably try to get to the bottom of even if it's not immediately causing problems. 就像编译器警告一样,我认为即使它没有立即引起问题,你也应该试着找到底线。 If I were Apple, I'd send my ads to apps that actually show them (I'm not saying they do do this), so there could be a financial aspect too. 如果我是Apple,我会将我的广告发送到实际显示它们的应用程序(我不是说他们会这样做 ),所以也可能有财务方面。

A couple of problems that I've seen: 我见过的几个问题:

  • The iAd frame is slightly off, maybe off the screen by just a pixel or two iAd框架略微偏离,可能只有一两个像素在屏幕外
  • You've accidentally created two iAds and one is on-screen and the other is hidden behind the first 您不小心创建了两个iAd,一个在屏幕上,另一个隐藏第一个iAd 后面

The answer from LearnCocos2D was the solution for me. LearnCocos2D的答案是我的解决方案。 Not sure if this is a specific issue with Cocos2D (which I am using). 不确定这是否是Cocos2D(我正在使用)的特定问题。 My problem was I was using the "new" style animations using blocks which Apple recommends using, animateWithDuration:delay:options:animations:completion: When I use these, I get the obscured warning. 我的问题是我正在使用Apple推荐使用的块的“新”风格动画,animateWithDuration:delay:options:animations:completion:当我使用这些时,我得到了模糊的警告。 I guess the problem is the view is partially obscured while it's animating in, hence the warning, but you can't make it completely visible before it's done animating, obviously, unless you just want to pop it on screen, which is ugly. 我想问题是视图在动画时被部分遮挡,因此警告,但是在它完成动画之前你不能让它完全可见,显然,除非你只是想在屏幕上弹出它,这很难看。

That's OK, because switching back to the "old" style animation using beginAnimations: and commitAnimations: did eliminate the warnings for me. 没关系,因为使用beginAnimations:和commitAnimations:切换回“旧”风格动画确实消除了对我的警告。 I'm curious if this warning means you are actually missing out on ad revenue or if it's just annoying but not actually a problem. 我很好奇这个警告是否意味着你实际上错过了广告收入,或者它只是令人烦恼但实际上并不是问题。

I got the same problem but the reason is I have OpenFeint notification bars on top of that, eg high scores, achievement unlocked, etc. It slides in and then slides out, does not stay for long, so I don't think it is a problem. 我有同样的问题,但原因是我有OpenFeint通知栏,例如高分,成就解锁等。它滑入然后滑出,不会停留很长时间,所以我不认为它是一个问题。

I you put ADS on the top, then user would not see OpenFeint notifications, that will be another problem, I do not know if this happens if you have ADS and OpenFeint on different locations of screen, I did not try it as my app's bottom screen is full of buttons, so only top of screen is available. 我把ADS放在顶部,那么用户就不会看到OpenFeint通知,这将是另一个问题,我不知道如果你在屏幕的不同位置有ADS和OpenFeint会发生这种情况,我没有尝试将它作为我的应用程序的底部屏幕上满是按钮,因此只有屏幕顶部可用。

Another option is to listen for status bar resize events and move the iAd when that happens so that it isn't respositioned offscreen (resulting in that warning and no served Ads). 另一种选择是监听状态栏调整大小事件并在发生这种情况时移动iAd,以便它不会在屏幕外重新定位(导致该警告并且没有提供广告)。

In your app delegate, tap into this function: 在您的app delegate中,点按此功能:

  • (void)application:(UIApplication *)application willChangeStatusBarFrame:(CGRect)newStatusBarFrame // Check newStatusBarFrame.size.height and animate your iAd frame up or down accordingly. (void)application:(UIApplication *)application willChangeStatusBarFrame:(CGRect)newStatusBarFrame //检查newStatusBarFrame.size.height并相应地向上或向下设置iAd帧的动画。

I am obtaining this message when I add a ADBannerView to a UIScrollView. 我在向UIScrollView添加ADBannerView时收到此消息。 In this case the ad may be obscured. 在这种情况下,广告可能会被遮挡。

I had code like this: 我有这样的代码:

if (animate)
{
    [UIView animateWithDuration:0.5 animations:^{
        self.adBannerView.frame = adBannerFrame;
        self.otherViewFrame.frame = otherViewFrame;
        }
     ];
}
else
{
    self.adBannerView.frame = adBannerFrame;
    self.otherViewFrame.frame = otherViewFrame;
}

and after some experimenting, I found that the order of the initializations should be reversed in both if and else legs. 经过一些实验,我发现初始化的顺序应该在if和else中都是相反的。

    self.otherViewFrame.frame = otherViewFrame;
    self.adBannerView.frame = adBannerFrame;

So the idea was not to let another view cover the AdBannerView, even for a few microseconds. 所以我的想法是不要让另一个视图覆盖AdBannerView,即使只有几微秒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM