Smart banners not updating on rotation

671 views
Skip to first unread message

Bob Bolt

unread,
May 13, 2015, 3:11:01 PM5/13/15
to google-adm...@googlegroups.com

I am trying to implement Admob's "smart" banners in my iOS app. But I am unable to find a way to deal with updating the ad when the device is rotated. I made a simple test app to try to find a way to make this work. According to the docs, setting the adSize property will cause the ad to reload. Although this works for the standard ads, it doesn't seem to work with the smart ones.

- (void)viewDidLoad {
[super viewDidLoad];
self.gadBannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
self.gadBannerView.adUnitID = @"ca-app-pub-3940256099942544/2934735716";
self.gadBannerView.rootViewController = self;
[self.gadBannerView loadRequest:[GADRequest request]];
[self.view addSubview:self.gadBannerView];
}

- (void)viewDidLayoutSubviews {
if (self.view.bounds.size.width < self.view.bounds.size.height) {
// portrait orientation
self.gadBannerView.adSize = kGADAdSizeSmartBannerPortrait;
} else {
// landscape orientation
self.gadBannerView.adSize = kGADAdSizeSmartBannerLandscape;
}
}


The ads stay at the size that they were when the object is init'd. I also tried setting the GADBannerView object to nil and then initing it again - also didn't work.




Vu Chau (MobileAds SDK Team)

unread,
May 13, 2015, 5:10:41 PM5/13/15
to google-adm...@googlegroups.com, bog...@gmail.com
Hi Bob,

In the log, do you see any ad request being made to the ad server after a change in device orientation?

If you haven't, please try running the app again using the following methods to detect orientation change:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInt
                               duration:(NSTimeInterval)duration {
  if (UIInterfaceOrientationIsLandscape(toInt)) {
    self.adBanner.adSize = kGADAdSizeSmartBannerLandscape;
  } else {
    self.adBanner.adSize = kGADAdSizeSmartBannerPortrait;
  }
}
Cheers,

Vu Chau
MobileAds SDK Team 

Bob Bolt

unread,
May 13, 2015, 5:43:45 PM5/13/15
to google-adm...@googlegroups.com, bog...@gmail.com
I never see any ad requests in the console, even when the object is init’d. I tried using the willRotateToInterfaceOrientation method like you suggested, but nothing changes. Whatever is defined as the size when the banner is init’d is always the size of the banner view. I am running xCode v 6.3.1.



Vu Chau (MobileAds SDK Team)

unread,
May 14, 2015, 4:23:35 PM5/14/15
to google-adm...@googlegroups.com, bb...@ualberta.ca, bog...@gmail.com
Hi Bob,

1) It seems the fact that the banner is defined in storyboard with constraints is overriding any adSize changes you make to the banner in code.  Therefore the ads are not refreshing.  When not using storyboard, a banner size change triggers a new request. 

2) We're looking into a potential bug on iOS 8 where the smart banner is calculating the wrong size on orientation changes.  We'll get back to you when there's an update.

Vu Chau
MobileAds SDK Team

Kenneth Ljungh

unread,
May 17, 2015, 2:49:42 PM5/17/15
to google-adm...@googlegroups.com, bb...@ualberta.ca, bog...@gmail.com
Hi,

I'm getting this too when creating banner in code, after rotation to landscape the banner width is still portrait width and ad content not updated. This worked fine in 7.1 but not in 7.2.2 for iOS 8 (only iOS 7).

zeb...@gmail.com

unread,
Feb 14, 2016, 7:07:59 PM2/14/16
to Google Mobile Ads SDK Developers, bog...@gmail.com
On rotate to landscape, this code shows a console error:

<Google> Unable to set adSize property. Not enough space to show ad with custom size, {959, 32}. Please use a size that fits the current screen bounds of {375, 667}.

Vu Chau (Mobile Ads SDK Team)

unread,
Feb 16, 2016, 12:48:59 PM2/16/16
to Google Mobile Ads SDK Developers, bog...@gmail.com
Hello, 

Make sure your AdView has enough space to accommodate the adjusted dimensions of the ad.  Check that the view doesn't have unnecessary paddings that might consume the space required by the ad.

Feel free to open a separate thread should you need further assistance with this issue,

Vu Chau
Mobile Ads SDK Team
Reply all
Reply to author
Forward
0 new messages