Evan
Evan

Reputation: 2040

How to lock phone in portrait mode with SwiftUI?

I'm making an application in SwiftUI and I don't want the user to be able to rotate their screen and be able to view the app in landscape mode. How can I do this?

Thanks.

Upvotes: 3

Views: 1555

Answers (2)

scraptechguy
scraptechguy

Reputation: 87

Alternative solution:

If the simple options on Project > Target > General > Deployment Info > Device Orientation are not enough for you, then try the following:

  1. Go to your project settings by selecting your project in Project Navigator.

enter image description here

  1. Select a target in the "TARGETS" section.

  2. Go to the "Info" tab.

  3. There are 3 arrays you may have to adjust: "Supported interface orientations (iPhone)", "Supported interface orientations", "Supported interface orientations (iPad)"

enter image description here

Upvotes: 2

George
George

Reputation: 30361

  1. Click on your project name with the blue icon next to it in Xcode.
  2. Select the "TARGETS" version of your project.
  3. Under "Deployment Info" in the General tab, change the "Device Orientation" settings.

Upvotes: 7

Related Questions