Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 517
Jeung Avatar asked Feb 16 '17 16:02

Jeung


4 Answers

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

UISupportedInterfaceOrientations

and

UISupportedInterfaceOrientations~ipad

like image 183
Klaas Avatar answered Nov 14 '22 09:11

Klaas


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.

like image 38
zephyr Avatar answered Nov 14 '22 10:11

zephyr


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

like image 5
Alvpjh Avatar answered Nov 14 '22 09:11

Alvpjh


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;
    }
like image 2
Roen Avatar answered Nov 14 '22 09:11

Roen