vendredi 6 mars 2015

iPhone app on iPad compatibility mode has strange layout in landscape (while I force portrait)

The Problem


As you can see, my iPhone app has a very strange layout when starting on iPad in landscape mode. I force the orientation of the app to portrait, but only on the iPad in landscape mode (when I start the app) seems to put the view 90 degrees turned in a portrait container. Also, the status bar seems to be a black bar and in the middle of the screen.


The app seems to work properly when I start it from portrait mode.


When starting the app with the iPad in landscape mode iPad compatibility mode landscape


When starting the app with the iPad in portrait mode iPad compatibility mode portrait


My code & configuration


The app has all 4 orientations enabled in the info.plist (because I dynamically switch orientation depending on which viewController is active).


I force the app to be portrait in the first viewController by using:



- (BOOL)shouldAutorotate {
return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}


I tried setting shouldAutorotate to NO, but this makes no difference.


The way I am starting my app in the AppDelegate didFinishLaunchingWithOptions is:



[[UIApplication sharedApplication] setStatusBarHidden:NO];

// 1
UIStoryboard *mainStoryboard = nil;
mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
// 2
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [mainStoryboard instantiateInitialViewController];
[self.window makeKeyAndVisible];
if ([self.window respondsToSelector:@selector(tintColor)]) {
self.window.tintColor = [UIColor whiteColor];
}


Strangely, everything goes 100% right with testing on an iPhone. Only the iPad compatibility mode has this issue.


Question


How can I solve this orientation problem for the iPad compatibility mode? It seems I am missing something that only applies for the iPad compatibility mode, as nothing like this happens for the iPhone.




Aucun commentaire:

Enregistrer un commentaire