I am struggling to get my UISplitViewController to always stay in landscape mode. The mothods that work with other ViewControllers don't seem to work here.
In my AppDelegate I have:
var supportedInterfaceOrientation: UIInterfaceOrientationMask = .all
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return supportedInterfaceOrientation
}
In my UISplitViewController I have:
let appDelegate = UIApplication.shared.delegate as! AppDelegate
override func viewDidLoad() {
super.viewDidLoad()
appDelegate.supportedInterfaceOrientation = .landscapeLeft
UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue, forKey: "orientation")
}
deinit {
appDelegate.supportedInterfaceOrientation = .all
}
override var shouldAutorotate: Bool {
return false
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscapeLeft
}
override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return .landscapeLeft
}
And I am presenting my UISplitViewController like this:
let vc = self.storyBoard.instantiateViewController(withIdentifier: "CompareSplitVC") as! CompareSplitViewController
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: {})
All of this has no effect and one of these are being called: shouldAutorotate, supportedInterfaceOrientations, preferredInterfaceOrientationForPresentation
What am I doing wrong?
Edit: I am getting this issue on iPad but not on iPhone.