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:
2
Answers
I had to set this key in my info.plist to false, so that
application(_:supportedInterfaceOrientationsFor:)
gets called on iPads:Thanks @lorem ipsum for the hint!
I also faced this issue in iPad, And got solution.
In your Info.Plist make this setting.
or
In your Project > General