Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

swift

iphone

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

portrait

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 !?

UPDATE:

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) {         super.viewDidAppear(animated)         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?

like image 457
MBH Avatar asked May 24 '15 23:05

MBH


2 Answers

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.

like image 88
Mohammed Elrashidy Avatar answered Oct 05 '22 03:10

Mohammed Elrashidy


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.

like image 39
user6685376 Avatar answered Oct 05 '22 03:10

user6685376