Is it a problem when an iAd may be obscured?

后端 未结 8 2337
执笔经年
执笔经年 2021-02-13 05:17

I added the ADBannerView to a view and when I load the app I get the following message:

ADBannerView: WARNING A banner view (0x7a023c0) has an ad but may be obscured. Th

相关标签:
8条回答
  • 2021-02-13 05:53

    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.

    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. So, as you start up your app,

    1. Your AdBannerView will attempt to load an advertisement, whether it is onscreen or not.

    2. Depending on whether or not it is successful, your AdBannerViewDelegate will receive either

      a) bannerViewDidLoadAd: (proceed to step 3) or

      b) bannerView: didFailToReceiveAdWithError: (the AdBannerView will try again on its own)

    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. 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. And so...

    4. How you handle the AdBannerView after it successfully loads its initial ad determines how it will behave in the future. 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.

    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. However, eCPM has been very, very low lately, so maybe that's not such an issue after all ;)

    0 讨论(0)
  • 2021-02-13 05:54

    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.

    A couple of problems that I've seen:

    • The iAd frame is slightly off, maybe off the screen by just a pixel or two
    • You've accidentally created two iAds and one is on-screen and the other is hidden behind the first
    0 讨论(0)
  • 2021-02-13 05:55

    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.

        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.

    0 讨论(0)
  • 2021-02-13 06:01

    The answer from LearnCocos2D was the solution for me. Not sure if this is a specific issue with Cocos2D (which I am using). 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. 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. 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.

    0 讨论(0)
  • 2021-02-13 06:03

    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).

    In your app delegate, tap into this function:

    • (void)application:(UIApplication *)application willChangeStatusBarFrame:(CGRect)newStatusBarFrame // Check newStatusBarFrame.size.height and animate your iAd frame up or down accordingly.
    0 讨论(0)
  • 2021-02-13 06:04

    To add to this discussion, I received this message when I modified the center property to move the ad just outside the screen. I use UIView animations to slide the ad onto the screen.

    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. Once it was loaded, I just had to make sure to set the hidden property to NO only after committing the animation:

    -(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;
    }
    
    0 讨论(0)
提交回复
热议问题