Jeung
Jeung

Reputation: 311

Xcode not obeying device orientation

I have set the Device Orientation to have only 'Portrait' checked in Xcode. However when I run my app in the simulator, it rotates in all orientations.

My Xcode setting

Showing correctly in Portrait (intended) and Landscape (not intended)

Anyone faced same issue before? Thanks

Upvotes: 31

Views: 11624

Answers (5)

zephyr
zephyr

Reputation: 1098

Maybe Xcode 14 fixed the bug, now it is kind to config device orientation on iPhone and iPad: enter image description here

Upvotes: 1

zephyr
zephyr

Reputation: 1098

In my case (Xcode 13.1),It works perfectly for me:

Follow steps:

  1. choose your target;
  2. select Build Settings;
  3. select All and Combined options;
  4. search orientation keywords
  5. notice Supported interface Orientations(iPhone), click the value of it on the right;
  6. delete the orientations you don't want.

Upvotes: 50

Roen
Roen

Reputation: 116

I have the same problem and costed my entire day onto it, i resolved by doing this: override the AppDelegate method

    func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
        

        if self.allowOrentitaionRotation {
            return .allButUpsideDown;
        }
        return .portrait;
    }

Upvotes: 2

Klaas
Klaas

Reputation: 22763

The "General"->"Deployment Info" UI in Xcode can be deceiving. Check these two keys in your info.plist:

UISupportedInterfaceOrientations

and

UISupportedInterfaceOrientations~ipad

Upvotes: 22

Alvpjh
Alvpjh

Reputation: 51

I have had the same problem (in physical devices). on iPhone it works fine but on iPad it does not work. The solution was to adjust the option of "devices" for both, in this case "landscape right". Landscape Right checkbox checked under Device Orientation below Deployment Info

Upvotes: 5

Related Questions