Launching in portrait orientation from the iPhone 6 Plus home screen in landscape orientation leads to incorrect orientation

The actual name for this question is longer than I can fit:

Launching an application whose root view controller only supports portrait orientation but otherwise supports landscape orientations on the iPhone 6 Plus, while the home screen is in landscape orientation, leads to an uncertain state when the application window is in landscape orientation, but the device is in portrait orientation.

In short, it looks like this:

sQ1o7.jpg

When it should look like this:

msCDu.jpg

Playback steps:

  • iPhone 6 Plus is running iOS 8.0.

  • An application whose plist supports an all-but-portrait-up-down orientation.

  • The application root view controller is the UITabBarController.

  • Everything, the tab bar controller and all its child controllers of the child views return a UIInterfaceOrientationMaskPortrait from supportedInterfaceOrientations .

  • On the iOS home screen.

  • Rotate to landscape (iPhone 6 Plus required).

  • Cold start application.

  • Result: broken interface orientations.

I can’t think of any other way to ensure orientation to portraits, except to turn off the landscape in general, which I can’t do: our web browser modal viewers need a landscape.

I even tried to subclass UITabBarController and override supportInterfaceOrientations to return a portrait-only mask, but that (even with all the other steps above) did not fix the problem.




Here is a link to an example project showing an error.




+56
ios iphone ios8 uiinterfaceorientation
Sep 23 '14 at 19:22
source share
12 answers

This is similar to a bug in iOS 8 when using the UITabBarController as the root view controller. A workaround is to use the UIViewController roller controller mainly 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]; 
+5
Sep 23 '14 at 19:22
source share

I had the same problem when launching our landscape app on iPhone 6 Plus.

Our fix was to remove the landscape-oriented interface orientations from plist through the project settings:

Removed landscape orientation

and implement the application: supportedInterfaceOrientationsForWindow: in the application deletion:

 - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return UIInterfaceOrientationMaskAllButUpsideDown; } 

Apparently, the information in your plist is to indicate which landmarks your application is allowed to run.

+63
Oct. 27 '14 at 22:41
source share

Setting statusBarOrientation for UIApplication seems to work for me. I put it in the application:didFinishLaunchingWithOptions: method in the application:didFinishLaunchingWithOptions: delegate.

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { application.statusBarOrientation = UIInterfaceOrientationPortrait; // the rest of the method } 
+35
01 Oct '14 at 4:06 on
source share

I had a very similar problem. I wanted to force portrait mode everywhere except video playback.

What I've done:

1) so that the orientation of the application is in the portrait in AppDelegate:

 -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if ([window.rootViewController.presentedViewController isKindOfClass:[MPMoviePlayerViewController class]]) { return UIInterfaceOrientationMaskAll; } return UIInterfaceOrientationMaskPortrait; } 

2) starting an empty modal view manager fixed a problem in my case. I run it in the viewDidLoad of the first view controller, which is at the root of my navigation controller (the first visibility controller visible after starting the application):

 - (void)showAndHideNamelessViewControllerToFixOrientation { UIViewController* viewController = [[UIViewController alloc] init]; [self presentViewController:viewController animated:NO completion:nil]; [viewController dismissViewControllerAnimated:NO completion:nil]; } 
+2
Oct 17 '14 at 16:10
source share

Please try the following code. This problem is probably caused by the size of the keywindow when starting the terrain.

 // in application:didFinishLaunchingWithOptions: ... self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; [self.window setFrame:[[UIScreen mainScreen] bounds]]; //<- ADD!! 
+1
Sep 24 '14 at 9:13
source share

I had no luck with a workaround for Jared using a universal container controller. I have already subclassed a tab bar controller with support for InterOfOrientations and no luck. Regardless of orientation 6+, after launch, the tab bar window reports frame = (0 0; 736 414)

So far, the only workaround I have found is to force window formatting after makeKeyAndVisible

[self.window makeKeyAndVisible]; self.window.frame = CGRectMake(0, 0, MIN(CGRectGetWidth(self.window.frame), CGRectGetHeight(self.window.frame)), MAX(CGRectGetWidth(self.window.frame), CGRectGetHeight(self.window.frame)));

+1
Sep 24 '14 at 19:41
source share

I want my application to open in landscape mode (and does not demonstrate the problem described above on the iPhone 6 Plus), so I set Landscape (left home button) and Landscape (right home button) as the only orientations allowed in my application PLIST file . This fixes the orientation problem when my application opens. However, I need the application to support portrait mode for one view only as long as I show the UIImagePickerController in my application, which Apple needs to display in portrait mode on the iPhone.

I could only maintain a portrait for this one view, while keeping my application open in landscape mode by including the following code in AppDelegate :

 -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { return UIInterfaceOrientationMaskAllButUpsideDown; } else { return UIInterfaceOrientationMaskAll; } } 
+1
Dec 31 '15 at 21:28
source share

For me, I had the same problem as jaredsinclair, but subclassing the UIViewController using the supportedInterfaceOrientations method did not solve the problem. Instead, I did exactly what he did in my appDidFinishLaunching method of my AppDelegate , and added my UITabBarController as a child to the normal UIViewController , and not to its subclass, and it will work!

0
24 Sep '14 at 13:49
source share

I am in the same situation, and [self.window setFrame: ...] does not work for me.

Adding the following at the end of the application: didFinishLaunchingWithOptions is the only thing I found that works. This makes the screen blink and not quite clean and efficient.

I added this at the end of the application: didFinishLaunchingWithOptions:

 UIViewController *portraitViewController = [[UIViewController alloc] init]; UINavigationController* nc = [[UINavigationController alloc] initWithRootViewController:portraitViewController]; [self.navController presentViewController:nc animated:NO completion:nil]; [self.navController dismissViewControllerAnimated:NO completion:nil]; [UIViewController attemptRotationToDeviceOrientation]; 
0
Sep 25 '14 at 19:39
source share

I had a similar problem with the fact that my application works both in landscape and portrait mode using the UITabBarController as the root view controller.

Whenever the application started in landscape mode, the view was wrong.

All I had to do was remove the rootview controller assignment in XIB. - Manually add it after starting the application:




  • (void) applicationDidFinishLaunching: (application UIApplication *) {application.statusBarHidden = YES;

    [self.window setRootViewController: self.tabBarController];




This fixed the problem.

0
Mar 01 '15 at 20:07
source share

Just delete all the elements in the supported orientation of the interface, except what you want (I only need a portrait) in info.plist, it will work for me enter image description here

0
Nov 02 '15 at 13:32
source share

just call [application setStatusBarOrientation: UIInterfaceOrientationPortrait animated: NO]; in the application delegate method - (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions

in fact now the device is UIInterfaceOrientationPortrait after starting, if you touch the input field, the keyboard is a portrait layout

-one
Apr 25 '16 at 13:58
source share



All Articles