locking orientation does not work on ipad ios 8 swift xcode 6.2 locking orientation does not work on ipad ios 8 swift xcode 6.2 ios ios

locking orientation does not work on ipad ios 8 swift xcode 6.2


You don't need extra code, I'm working on Xcode 7.0.1, I noticed that when I lock screen orientation to only portrait, it locks only in iPhones, to lock it in iPads also, you need to select iPad from Devices (instead of Universal) and check portrait and uncheck the others and then return Devices to Universal again, as I found that Universal only reflect in iPhones, it maybe some kind of bug in Xcode.


I also had same problem. What worked for me was -> Select iPad instead of Universal in Device Type -> Uncheck the other three options except Portrait -> Select Universal again. Done.


You can override your view controller property shouldAutorotate

override var shouldAutorotate: Bool {    return false }

If your view controller is embedded in a Navigation controller you can create a custom Navigation controller:

class PortraitNavigationController: UINavigationController {    override var shouldAutorotate: Bool {        return false     }    /*    // MARK: - Navigation    // In a storyboard-based application, you will often want to do a little preparation before navigation    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {        // Get the new view controller using segue.destinationViewController.        // Pass the selected object to the new view controller.    }    */}