locking orientation does not work on ipad ios 8 swift xcode 6.2

后端 未结 5 1542
广开言路
广开言路 2020-12-06 04:24

I locked the app orientation to portrait from the general app setting like this

\"portrait\"

but still

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 04:53

    You can override your view controller property shouldAutorotate

    override var shouldAutorotate: Bool {
        return false 
    }
    

    If your view controller is embedded in a Navigation controller you can create a custom Navigation controller:

    class PortraitNavigationController: UINavigationController {
    
        override var shouldAutorotate: Bool {
            return false 
        }
        /*
        // MARK: - Navigation
    
        // In a storyboard-based application, you will often want to do a little preparation before navigation
        override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
            // Get the new view controller using segue.destinationViewController.
            // Pass the selected object to the new view controller.
        }
        */
    }
    

提交回复
热议问题