How to lock orientation of one view controller to portrait mode only in Swift

后端 未结 16 2205
梦谈多话
梦谈多话 2020-11-22 12:07

Since my app got support for all orientation. I would like to lock only portrait mode to specific UIViewController.

e.g. assume it was Tabbed Application and when Si

16条回答
  •  故里飘歌
    2020-11-22 12:40

    Create new extension with

    import UIKit
    
    extension UINavigationController {
        override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {
            return .portrait
        }
    }
    
    extension UITabBarController {
        override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {
            return .portrait
        }
    }
    

提交回复
热议问题