how to lock portrait orientation for only main view using swift

后端 未结 16 1920
野性不改
野性不改 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 13:58

    In iOS8, if you want to lock some especific ViewController, create an extension of UINavigationController (in the case you use it):

    extension UINavigationController {
    public override func shouldAutorotate() -> Bool {
    if visibleViewController is YourViewController {
        return false
    }
    return true
    }}
    

提交回复
热议问题