在我的 AppDelegate 中,我正在使用一个函数来旋转我的设备并锁定方向。
iPhone 只能是纵向的,iPad 只能是横向的。
它适用于 iPhone,但在 iPad 上永远不会调用以下函数:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
print("Test")
return AppDelegate.orientationLock
}
我认为它在我切换到“SwiftUI Life Cicle”之前在 iPad 上工作,但我不确定这是否是它停止工作的时间点:
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
对于 iPad,info.plist 也设置为“仅限横向”,但应用程序无论如何都以纵向模式启动,这也很奇怪:


