How to force view controller orientation in iOS 8?

前端 未结 25 2393
太阳男子
太阳男子 2020-11-22 13:11

Before iOS 8, we used below code in conjunction with supportedInterfaceOrientations and shouldAutoRotate delegate methods to force app orie

25条回答
  •  旧时难觅i
    2020-11-22 13:30

    On Xcode 8 the methods are converted to properties, so the following works with Swift:

    override public var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.portrait
    }
    
    override public var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
        return UIInterfaceOrientation.portrait
    }
    
    override public var shouldAutorotate: Bool {
        return true
    }
    

提交回复
热议问题