Launching into portrait-orientation from an iPhone 6 Plus home screen in landscape orientation results in wrong orientation

前端 未结 13 1700
南方客
南方客 2020-12-22 23:21

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 otherw

13条回答
  •  旧时难觅i
    2020-12-22 23:26

    I'm in the same situation, and doing [self.window setFrame:...] doesn't work for me.

    Adding the following at the end of application:didFinishLaunchingWithOptions is the only thing I've found that works. It makes the screen blink and isn't exactly clean and efficient.

    I added this at the end of 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];
    

提交回复
热议问题