how to lock portrait orientation for only main view using swift

后端 未结 16 1888
野性不改
野性不改 2020-12-07 13:38

I have created an application for iPhone, using swift, that is composed from many views embedded in a navigation controller. I would like to lock the main v

16条回答
  •  死守一世寂寞
    2020-12-07 14:06

    This is the syntax for Swift 3 (XCode 8.2 beta), where these methods where converted to properties:

    extension UINavigationController {
        override open var shouldAutorotate: Bool {
            return false
        }
    }
    
    class ViewController: UIViewController {
    
        /*
                ...
        */
    
        override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
            return UIInterfaceOrientationMask.portrait
        }
    }
    

提交回复
热议问题