swift - AppDelegates 函数“supportedInterfaceOrientationsFor”不会在 iPad 上调用
问题描述
在我的 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 也设置为“仅限横向”,但应用程序无论如何都以纵向模式启动,这也很奇怪:
解决方案
推荐阅读
- spring-boot - 无法在 Spring Boot 应用程序中连接到 Active Directory 并显示“'userDn' not set”消息
- stata - 循环回归?
- python - 在bash中的一系列脚本命令中重定向stderr并获取失败脚本的名称的方法?
- node.js - React 和 Node 部署问题 - 部署成功但不显示前端部分
- python - 我可以添加什么样的代码,这样我就可以避免有时出现的验证码或填充特定的验证码
- javascript - JavaScript 帮助/循环问题
- python-3.x - 在 Python 中,是否有更简单的方法来遍历两个不同大小的列表?
- html - justify-content-center 在轮播上不起作用
- vue.js - Vue 嵌套转换无法按预期工作
- redux-mock-store - 使用 jest 模拟多个 Axios 调用