AdMob GADBannerView loads advertisement outside of

2019-06-04 05:42发布

问题:

I'm trying to use AdMob mediation and I've followed the instructions in the iOS Quick Start document for AdMob located here. It works, and I can see the test ad, but the advertisement seems to load outside of the visible area of the GADBannerView. I can drag the advertisement into the visible area, but when the ad refreshes, the banner again loads outside of the viewable area. I can't figure out what I'm doing wrong, nor do I see any way of fixing this, since the AdMob iOS SDK seems to handle everything once you've loaded the view. Any help is much appreciated. I've included an animation to better illustrate my issue.

(The view with the white background is presented modally when the toolbar button is touched on the view with the blue background and the GADBannerView is initially loaded with a black background for convenience.)

EDIT: I've discovered that the issue seems to have something to do with embedding the view controller in a navigation controller. It doesn't happen when the navigation controller is not present, then, after adding the navigation controller, the ad exhibits this behavior.

回答1:

I experienced a similar issue, when trying to nest a GADBannerView in a nib in the following way:

  • nib
  • custom View Controller
  • UIView
  • custom View class
  • which then instantiated the GADBannerView in code

A workaround I found was to uncheck the "Extend Edges ... Under Top Bars" checkbox in the view controller's nib's attributes inspector.

This of course means that the navigation controller shouldn't be translucent or you'll get some ugly fades behind the navigation controller.



标签: ios admob