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


I locked the app orientation to portrait from the general app setting like this


but still when i run my application on ipad, it rotates!?

so where should i lock the orientation ?

why apple added this feature to settings, while it is not working !?


I tried to implement this viewController as the general for all the viewController as well.

import Foundation
import UIKit

class GeneralViewController: UIViewController {

    override func viewDidAppear(animated: Bool) {
        let value = UIInterfaceOrientation.Portrait.rawValue
        UIDevice.currentDevice().setValue(value, forKey: "orientation")

    override func supportedInterfaceOrientations() -> Int {
        return Int(UIInterfaceOrientationMask.Portrait.rawValue)

    override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
        return UIInterfaceOrientation.Portrait

    override func shouldAutorotate() -> Bool {
        return false

this pic taken from the main navigationController of my app.

Pic of answer 1

still did not work!

how on earth this thing works?

Best Solution

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.