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.
source share