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:
How can I get the iPad app to only allow landscape orientation in SwiftUI?
I am running Xcode 12.4
2
Answers
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.
Yes you can change SwiftUI app landscape orientation only
Here is the video demo