4

I've downloaded the latest AdMob SDK for iOS, but I've a problem with the banner offset as shown in following picture

picuter

Here the code I'm using for showing positioning it

bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; // kGADAdSizeSmartBannerPortrait

CGRect bannerFrame = bannerView.frame;
bannerFrame.origin.y = [[UIScreen mainScreen] bounds].size.height - bannerFrame.size.height;
[bannerView setFrame:bannerFrame];
bannerView.adUnitID = AD_NOB_BANNER_UNIT_ID;
bannerView.rootViewController = self;
[self.view addSubview:bannerView];

[bannerView loadRequest:[GADRequest request]];

I've set the background color to green and the banner background color to gray to check whether the box is correctly positioned or not. The box position is correct {{0, 430}, {320, 50}} but the banner has a wrong offset.

If I move my finger on it, I can scroll up it and it will fits the screen...but its offset is not correct, if I scroll down again I can see the same offset problem. Apparently I haven't found any method to set this offset.

Did somebody faced and solved the same issue?

Bagbyte
  • 845
  • 2
  • 18
  • 34
  • Having the same issue right now. Everything is fine on iOS < 8 running 6.9.2 but iOS 8 with 6.12 is offset what looks like 10,10 – JamesSwift Oct 10 '14 at 20:41

1 Answers1

1

This has the same symptoms as a problem with iOS 7 UIWebView that is discussed here and here.

Add the following code before creating your bannerView:

  UIView *view = [[UIView alloc] init];
  [self.view addSubview:view];

Or if you need do do it afterwards:

  UIView *view = [[UIView alloc] init];
  [self.view insertSubview:view belowSubview:bannerView];

What seems to be happening is that iOS attempts to set the scroll offset on the last subview of the root view. Having the added view stops this from happening to your bannerView.

Community
  • 1
  • 1
ThomasW
  • 16,981
  • 4
  • 79
  • 106