I want the general orientation of my app to be portrait, but for one specific UIViewController
(VC2B) I want the user to be able to tilt the device for landscape orientation. (VC2B has a navigation bar)
I have tried different types of code but without luck. Ideally I would like to to enable rotation in only UIViewController
(VC2B). But this seems impossible, instead it seems you have to enable all the orientations in the General section and then turn them off programatically - is this really true?
Anyway I have tried various things
override func shouldAutorotate() -> Bool {
return true
}
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientation.LandscapeLeft.rawValue) | Int(UIInterfaceOrientation.LandscapeRight.rawValue) | Int(UIInterfaceOrientation.Portrait.rawValue)
}
The below answer suggest overriding shouldAutorotate
to false, but that does not work if the page is loaded in landscape mode, then it is just stuck on landscape.
Allow all orientations for only one view controller
Question: How can I in a tidy way, without adding code to all my UIViewController
s, allow multiple orientations for only one UIViewController
?