GADInterstitial and landscape orientation

629 views
Skip to first unread message

Ingmar Stein

unread,
Dec 23, 2011, 3:57:04 AM12/23/11
to google-adm...@googlegroups.com
Hi all,

I'm currently using the AdMob SDK to add ads to an existing iPad application.
The customer wants an interstitial to be displayed not only when the app is started for the first time but also when it is resumed.
Therefore, I added the following code to my app delegate:

- (void)applicationDidBecomeActive:(UIApplication *)application

{

if (!self.window.rootViewController.modalViewController) {

GADRequest *request = [GADRequest request];

request.testDevices = [NSArray arrayWithObjects:

  GAD_SIMULATOR_ID,                               // Simulator

  nil];


GADInterstitial *interstitial = [[GADInterstitial alloc] init];

interstitial.adUnitID = @"some_ad_unit_id";

interstitial.delegate = self;

UIImage *splashImage = nil;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

// first try orientation-specific launch images

if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown) {

splashImage = [UIImage imageNamed:@"Default-PortraitUpsideDown.png"];

} else if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft) {

splashImage = [UIImage imageNamed:@"Default-LandscapeLeft.png"];

} else if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {

splashImage = [UIImage imageNamed:@"Default-LandscapeRight.png"];

}

// if there wasn't found a orientation-specific launch-image

// try the ones for only Portrait/Landscape

if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) {

splashImage = [UIImage imageNamed:@"Default-Portrait.png"];

} else {

splashImage = [UIImage imageNamed:@"Default-Landscape.png"];

}

}


// iPhone, or still no image found on iPad -> use Default.png

if (!splashImage) {

splashImage = [UIImage imageNamed:@"Default.png"];

}


[interstitial loadAndDisplayRequest:request usingWindow:self.window initialImage:splashImage];

}

}


However, the call to loadAndDisplayRequest forces the device orientation to portrait mode - even when the app is resumed while holding the device in landscape orientation. I assume this is a bug in the SDK and maybe related to the following post on StackOverflow:

It would be great if someone from the AdMob team could look into this issue.

Regards,
Ingmar

Reply all
Reply to author
Forward
0 new messages