I am making an iPhone app and I need it to be in portrait mode, so if the user moves the device sideways, it does not automatically rotate. How can I do this?
I am making an iPhone app and I need it to be in portrait mode, so if the user moves the device sideways, it does not automatically rotate. How can I do this?
Most simple solution separate for iPhone and iPad (Universal) - its remove unnecessary orientation in the info.plist file or Project -> Info -> Custom iOS Target Properties.
Just add or remove orientation item from list:
In Xcode 13.3.1, simply unchecking undesired orientations does not prevent an app from supporting all rotations. It is necessary to enter the Build Settings tab and manually remove any orientations from the following fields that you do not wish to support:

In my case, my app will now only support portrait orientation.
If you want to disable landscape orientation for both iPhone and iPad.
Go to Targets and Go to the General tab. See the below screen and deselect landscape left and landscape right.
Here in this case only iPhone landscape mode will be disabled not for iPad. For iPad all modes are anabled. If you want select device option from Universal to iPad. It will looks like this. See below screen.
Now you need to deselect all modes except Portrait for iPad. See below screenshot.
Now you successfully disabled all modes except Portrait for all devices.
If you created a new Xcode 13.3 project and unchecked unnecessary orientation checkmarks in the Project > General > Deployment and it didn't help. Check the Target > Build Settings - there are 2 rows which override global settings.
I've had the same problem on Xcode 13.0 even though I set the device orientation only Portrait.
Adding these 2 lines to Info.plist solved my problem.