melicent
melicent

Reputation: 1251

Lock landscape orientation in Swift iOS9

I'm struggling with locking my app in landscape mode. I only have one ViewController, and it's not in a NavigationController. Inside the view controller I have the following code:

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.LandscapeLeft
}
override func shouldAutorotate() -> Bool {
    return false;
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
    return UIInterfaceOrientation.LandscapeLeft
}

In the "General" tab of the settings I have the following:

General

And in the ViewController's attributes I have this:

Attributes

I've tried using UIDevice.currentDevice().setValue(...) in the ViewDidLoad, but that had no effect. I'm trying to run this app on an iPad mini and I'm totally at a loss. Any help would be much appreciated.

Upvotes: 2

Views: 2028

Answers (1)

melicent
melicent

Reputation: 1251

Update: I finally found the answer to this. In the "Supporting Files" folder, the info.plist file has attributes for "Supported Interface Orientations" and "Supported Interface Orientations (iPad)".

enter image description here

Evidently this was overriding all my other selections and code, since I was running the app on an iPad. Removing the unwanted orientations fixed my issue. Hope this helps someone!

Upvotes: 7

Related Questions