How to lock orientation in Xcode

I am designing an app in Xcode 6. It has 4 view controllers. I need two view controllers to be in locked in protrait orientation and the other two to be locked in landscape orientation. The initial view controller is a navigation view controller. I have searched all over the web and none of the solutions I found seem to work. The one that looks like it should work is to add the following code to each view controller:


override func shouldAutorotate() -> Bool {

return true

}

override func supportedInterfaceOrientations() -> Int {

return Int(UIInterfaceOrientationMask.Portrait.rawValue)

}

override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {

return UIInterfaceOrientation.Portrait

}


This does not work, the view still rotates. I put print statements inside each of these functions and only the second one was executed.


Any ideas on how to achieve this?

iPhone or iPad? Do they (which?) need to be locked during launch?

How to lock orientation in Xcode
 
 
Q