I know this question was already asked in here, here and here. I tried all possible ways but wasn't successful.
I'm trying to develop an application in Swift (iOS 8), in which only one view controller can be viewed in all orientations others in only portrait.
For this, I have enabled only Portrait
mode in Target->General->Device Orientation (because I want the application to operate only in portrait mode except one view controller).
I have added below code to the view controller that I want to operate in all orientations:
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientationMask.All.rawValue)
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.LandscapeLeft;
}
override func shouldAutorotate() -> Bool {
return true;
}
But couldn't rotate it in landscape mode.
Do the following:
in each
ViewController
, override the autorotation function with either true or false(
true
for the one that should rotate,false
for the others):Hope that helps :)
Try this in your perticular viewController which you want in all orientation, in viewWillAppear:
and don't forget to allow orientations in Target->General->Device Orientation
Give it a try