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

前端 未结 13 1787
南方客
南方客 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条回答
  •  难免孤独
    2020-12-22 23:46

    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) and Landscape (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 a UIImagePickerController 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:

    -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
    
            return UIInterfaceOrientationMaskAllButUpsideDown;
    
        } else {
    
            return UIInterfaceOrientationMaskAll;
    
        }
    
    }
    

提交回复
热议问题