ios - iPadOS 13 上的屏幕旋转故障

标签 ios user-interface ipad screen-rotation ipados

我一直在处理 iPadOS 13.1.3 上与设备方向相关的 UI 故障。对此有任何解决方案或解决方法吗?


问题

描述

让屏幕 A 以模态方式显示屏幕 B。屏幕 A 仅锁定为纵向,屏幕 B 支持所有方向。如果显示屏幕 A,然后设备旋转到横向,然后屏幕 B 即将显示,屏幕 A 首先被错误地调整大小,这会导致奇怪的故障。

图片

左图是在 iPadOS 13.1.3 上拍摄的,会产生 UI 故障。右边的图像是在安装了 iOS 12.4.1 的 iPad 上录制的,布局正确。所有附加图像都是下面链接的 github 项目的一部分。

项目

请随时使用 this 仔细查看此问题。存储库。

谢谢。


编辑:

iPadOS 13.2 上不再出现该故障。

最佳答案

我是这样解决的:

  • 删除 func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) 的实现。让我们让 View Controller 处理这个。

  • 在 VC1 中:

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        .portrait
    }
    

    同时删除“hacky solution”。

  • 在 VC2 中:

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        .all
    }
    override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
        .portrait
    }
    

所以我们得到的是 VC2 最初以纵向显示,但随后可以旋转。

如果你想让VC2出现后立即旋转成横屏,那么加上这个:

var appeared = false
override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    appeared = true
    UIViewController.attemptRotationToDeviceOrientation()
}

关于ios - iPadOS 13 上的屏幕旋转故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58521687/

相关文章:

ios - 从解析中检索到的数据顺序

ios - 如何使用 SearchBar TableView 在字典中搜索对象?

iphone - iOS Safari 页面上方奇怪的灰色空间

iphone - 使用 searchBar 搜索并显示 google 结果 :textDidChange:

ipad - iPad 上 contenteditable 的解决方法

ios - 无法通过 Storyboard 动画化事件指示器

ios - Xamarin Forms 上的错误 MT0026

ajax - 优雅降级 - 何时考虑

具有持久界面的 Linux 命令行应用程序

java - 在java中将逻辑与GUI分离