Search code examples
iosswiftswiftuilandscape-portraitswiftui-navigationlink

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.


Solution

    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.