skip to Main Content

In my AppDelegate I am using a function to rotate my device and lock the orientation.

iPhone shall be portrait only, and iPad landscape only.

It works on iPhones, but the following function does never get called on iPads:

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
    print("Test")
    return AppDelegate.orientationLock
}

I think it was working on iPads before I switched to "SwiftUI Life Cicle" but I am not absolutely sure if this was the point of time, where it stopped working:

 @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

The info.plist is also set to "Landscape only" for iPads, but the app starts in portrait mode anyway, which is strange too:

info.plist

2

Answers


  1. Chosen as BEST ANSWER

    I had to set this key in my info.plist to false, so that application(_:supportedInterfaceOrientationsFor:) gets called on iPads:

    <dict>
        <key>UIApplicationSupportsMultipleScenes</key>
        <false/>
    </dict>
    

    Thanks @lorem ipsum for the hint!


  2. I also faced this issue in iPad, And got solution.

    In your Info.Plist make this setting.
    enter image description here

    or
    In your Project > General

    enter image description here

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