Search code examples
iosviewadmobuiinterfaceorientationautoresize

Cannot resize AdMob's view upon orientation change


What I tried so far is, in viewDidLoad, I called

self.bannerView.autoresizingMask=UIViewAutoresizingFlexibleWidth;

and

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)newInterfaceOrientation duration:(NSTimeInterval)duration {
    if (newInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || newInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        self.bannerView.frame=CGRectMake(0.0,
                                         0.0,
                                         480.0,
                                         GAD_SIZE_320x50.height);
    }
    // Position the UI elements for portrait mode
    else {
        self.bannerView.frame=CGRectMake(0.0,
                                         0.0,
                                         GAD_SIZE_320x50.width,
                                         GAD_SIZE_320x50.height);
    }
}

Both of these didn't work for me.


Solution

  • Hmm, I don't think that AdMob's creatives can stretch to fit the size of the screen when in landscape. So despite the fact that you're stretching the frame of the view to fit, the ad itself I think will stay the same size.

    This means you should still see an ad come in on orientation changes, it will just look like it's the same size (make sure to make another request for an ad in the willAnimateRotationToInterfaceOrientation: method to see this).