AdMob smart banner ads not updating on the device

I am trying to implement Admob smart banners. I can’t find a way to handle updating the ad when I rotate the device. According to AdMob docs, setting the adSize property will reload the ad. This works for standard banners, but it doesn't seem to work with smart banner ads.

 - (void)viewDidLoad { [super viewDidLoad]; self.gadBannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait]; self.gadBannerView.adUnitID = @"myBannerID"; 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; NSLog(@"portrait banner size: %@",NSStringFromCGRect(self.gadBannerView.frame)); } else { // landscape orientation self.gadBannerView.adSize = kGADAdSizeSmartBannerLandscape; NSLog(@"landscape banner size: %@",NSStringFromCGRect(self.gadBannerView.frame)); } } 

Ads remain at the size that was during the initialization of the object. I also tried setting the GADBannerView object to nil and then initializing it again, but that didn't work.

+6
source share
1 answer

I had the same issue with the 7.2.2 AdMob iOS SDK.

v7.3.1 includes a fix for your problem (see AdMob for iOS Release Notes ):

Fixed the regression introduced in 7.2.0, where smart banners are displayed incorrectly in the landscape on iOS 8.

+1
source

Source: https://habr.com/ru/post/987150/


All Articles