The actual title for this question is longer than I can possibly fit:
Launching an app whose root view controller only supports portrait-orientation but which otherwise supports landscape orientations on an iPhone 6 Plus while the home screen is in a landscape orientation results in a limbo state where the app's window is in a landscape orientation but the device is in a portrait orientation.
In short, it looks like this:
When it is supposed to look like this:
Steps to Reproduce:
iPhone 6 Plus running iOS 8.0.
An app whose plist supports all-but-portrait-upside-down orientations.
The root view controller of the app is a UITabBarController.
Everything, the tab bar controller and all its descendent child view controllers return
UIInterfaceOrientationMaskPortrait
fromsupportedInterfaceOrientations
.Start at iOS home screen.
Rotate to landscape orientation (requires iPhone 6 Plus).
Cold-launch the app.
Result: broken interface orientations.
I can't think of any other way to enforce a portrait orientation except to disable landscape altogether, which I can't do: our web browser modal view controllers need landscape.
I even tried subclassing UITabBarController and overriding supportedInterfaceOrientations to return the portrait-only mask, but this (even with all the other steps above) did not fix the issue.
Here's a link to a sample project showing the bug.
Please try the following code. Probably this problem caused by size of keywindow on landscape launch.
Just Remove All the items in Supported interface orientation except what you want (i need only Portrait) in info.plist , it will work for me
I had a similar issue is with my app runs both in landscape and portrait with a UITabBarController as root view controller.
Whenever the app was launched when in Landscape mode, the view was incorrect.
All I had to do: - remove rootview controller assignment in the XIB. - Manually add it in once the app is launched:
(void)applicationDidFinishLaunching:(UIApplication *)application { application.statusBarHidden = YES;
[self.window setRootViewController:self.tabBarController];
That fixed the problem.
just call [application setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; in app delegate method - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
in fact the device now is UIInterfaceOrientationPortrait after Launching ,if you touch an inputField ,the keyboard is portrait layout
This appears to be a bug in iOS 8 when using a UITabBarController as a root view controller. A workaround is to use a mostly vanilla UIViewController as the root view controller. This vanilla view controller will serve as the parent view controller of your tab bar controller:
I only want my app to open in landscape mode (and not exhibit the problem you describe above on the iPhone 6 Plus), so I set
Landscape (left home button)
andLandscape (right home button)
as the only orientations allowed in my app's PLIST file. This fixes the orientation problem when my app opens. However, I need my app to support portrait mode for one view only since I display aUIImagePickerController
in my app, which Apple requires to be shown in portrait mode on iPhone.I was able to support portrait for that one view only, while keeping my app opening in landscape mode, by including the following code in
AppDelegate
: