Launching into portrait-orientation from an iPhone 6 Plus home screen in landscape orientation results in wrong orientation
I had the same issue when launching our app in landscape on an iPhone 6 Plus.
Our fix was to remove landscape supported interface orientations from the plist via project settings:
and implement application:supportedInterfaceOrientationsForWindow: in the app delegate:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return UIInterfaceOrientationMaskAllButUpsideDown;}
Apparently the information in your plist is to specify what orientations your app is allowed to launch to.
Setting the statusBarOrientation
of the UIApplication
seems to work for me. I placed it in the application:didFinishLaunchingWithOptions:
method in the app delegate.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ application.statusBarOrientation = UIInterfaceOrientationPortrait; // the rest of the method}
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:
///------------------------/// Portrait-Only Container///------------------------@interface PortraitOnlyContainerViewController : UIViewController@end@implementation PortraitOnlyContainerViewController- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait;}@end// Elsewhere, in app did finish launching ...PortraitOnlyContainerViewController *container = nil;container = [[PortraitOnlyContainerViewController alloc] initWithNibName:nil bundle:nil];[container addChildViewController:self.tabBarController];self.tabBarController.view.frame = container.view.bounds;[container.view addSubview:self.tabBarController.view];[self.tabBarController didMoveToParentViewController:container];[self.window setRootViewController:container];