I want to present a UIView
controller already in landscape mode and disable any other rotations for this UIViewController
. I tried the following, but the user can still rotate out of landscape.
override func viewDidLoad() {
super.viewDidLoad()
applyLandscapeAndLock()
build()
// Do any additional setup after loading the view.
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.LandscapeLeft
}
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> Int {
return UIInterfaceOrientation.LandscapeLeft.rawValue
}
func applyLandscapeAndLock() {
let value = UIInterfaceOrientation.LandscapeLeft.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}