Force landscape mode in one ViewController using Swift

后端 未结 19 1243
情书的邮戳
情书的邮戳 2020-12-02 07:44

I am trying to force only one view in my application on landscape mode, I am calling

override func shouldAutorotate() -> Bool {
    print(\"shouldAutoro         


        
19条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 08:12

    Works in Swift 2.2

     func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
        if self.window?.rootViewController?.presentedViewController is SignatureViewController {
    
            let secondController = self.window!.rootViewController!.presentedViewController as! SignatureViewController
    
            if secondController.isPresented {
    
                return UIInterfaceOrientationMask.LandscapeLeft;
    
            } else {
    
                return UIInterfaceOrientationMask.Portrait;
            }
    
        } else {
    
            return UIInterfaceOrientationMask.Portrait;
        }
    }
    

提交回复
热议问题