iOS7 iPad Landscape only app, using UIImagePickerController

前端 未结 6 831
北荒
北荒 2020-11-29 23:16

I believe this is a common issue and many answers don\'t work anymore, many just partial, if you are under iOS7 and your iPad app is Landscape only, but you want to use the

6条回答
  •  情深已故
    2020-11-29 23:59

    Swift 4 solution

    Make sure that when you are having the ViewController embedded in a NavigationViewController to have the fix there. It won't work adding this restriction to the ViewController then...

    import UIKit
    
    class MainNavigationViewController: UINavigationController {
    
        override var shouldAutorotate: Bool {
            return true
        }
    
        override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
            return .landscape
        }
    }
    

    And of course the code mentioned above for the AppDelegate:

    func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
        return .all
    }
    

    Btw this is only necessary for iOS 10 and below. Apple seems to have fixed it from iOS 11 and above...

提交回复
热议问题