locking orientation does not work on ipad ios 8 swift xcode 6.2

后端 未结 5 1539
广开言路
广开言路 2020-12-06 04:24

I locked the app orientation to portrait from the general app setting like this

\"portrait\"

but still

5条回答
  •  情歌与酒
    2020-12-06 04:58

    This would be a comment added to Mohammed Elrashidy solution but I don't have the reputation to make comments. I am using XCode 9.1 and Swift 3.

    My app requires some graphing screens to autorotate but all the other screens to remain fixed. My issue was that the "iPad" device configuration in General > Deployment Info was configured inconsistently with the iPhone and Universal devices. I had "Portrait", "Landscape Left" and "Landscape Right" checked for iPhone and Universal but all of the orientations checked for iPad (including "Upside Down"). Simply unchecking "Upside Down" caused the iPad device to honor the shouldAutorotate and supportedInterfaceOrientations calls in my Swift logic.

    My Info.plist now looks like the following and I can programmatically turn autorotation on or off for the iPad.

    UISupportedInterfaceOrientations
    
        UIInterfaceOrientationPortrait
        UIInterfaceOrientationLandscapeLeft
        UIInterfaceOrientationLandscapeRight
    
    UISupportedInterfaceOrientations~ipad
    
        UIInterfaceOrientationPortrait
        UIInterfaceOrientationLandscapeLeft
        UIInterfaceOrientationLandscapeRight
    
    

提交回复
热议问题