skip to Main Content

I’ve created a swiftUI app and noticed that no matter what settings I change, the iPad version of the app will always allow portrait orientation. The iPhone version of the app works as expected.

Here are some screenshots of my settings:

enter image description here

enter image description here

How can I get the iPad app to only allow landscape orientation in SwiftUI?
I am running Xcode 12.4

2

Answers


  1. Unfortunately this does not seem to be supported with the SwiftUI application lifecycle, even with use of UIApplicationDelegateAdaptor. This may be an intentional design decision to encourage developers to design resizable window applications (for multitasking & macOS).

    If you switch to the UIKit lifecycle by replacing your App struct with UIApplicationDelegate/UISceneDelegate, you’ll be able to allow only landscape orientation.

    Login or Signup to reply.
  2. Yes you can change SwiftUI app landscape orientation only

    • Select iPad and deselect iPhone
    • Set the orientations support as required
    • Un-set Supports multiple windows if you want
    • Switch back to iPhone and iPad

    Here is the video demo
    video demo

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search