gpt4 book ai didi

swift - AppDelegates 函数 "supportedInterfaceOrientationsFor"不会在 iPad 上被调用

转载 作者:行者123 更新时间:2023-12-04 08:09:43 24 4
gpt4 key购买 nike

在我的 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 也设置为“Landscape only”,但应用程序仍然以纵向模式启动,这也很奇怪:

info.plist

最佳答案

我在 iPad 上也遇到了这个问题,并找到了解决方案。

在您的 Info.Plist 中进行此设置。 enter image description here

或者在您的项目 > 常规

enter image description here

关于swift - AppDelegates 函数 "supportedInterfaceOrientationsFor"不会在 iPad 上被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66041654/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com