I've got the following code which works fine on iPhone, but not on iPad. It should lock the orientation on landscape and disable autorotation only for THIS viewcontroller (not for the whole app - NOT changing attributes in the project/info.plist file):
override var shouldAutorotate : Bool {
return false
}
and in viewDidLoad()
:
let landscapeValue = UIInterfaceOrientation.landscapeRight.rawValue
UIDevice.current.setValue(landscapeValue, forKey: "orientation")
How can I lock the orientation to landscape and disable rotation for my current ViewController (like it is already perfectly working on iPhone)?
My Specs:
XCode - 9.1 Build 9B55
Swift - 4.0.2
Tested on iPad Air - iOS 10.3.3