iPad 不会自动旋转到横向

时间:2020-12-31 14:15:45

标签: ios xcode ios-simulator

我有一个项目,我的屏幕需要在横向和纵向方向上进行测试,并且需要在我运行一些 UI 测试用例时自动发生,我使用以下代码。

let value = UIInterfaceOrientation.landscapeRight.rawValue
UIDevice.current.setValue(value, forKey: "orientation")

这在 iPhone 模拟器上运行良好,模拟器将自身转为横向模式,但在 iPad 模拟器上不会自行旋转

我尝试过的事情: 将以下代码添加到

UIViewController.attemptRotationToDeviceOrientation()

也没有工作并检查方向是否受 iPad 支持或不使用:

self.supportedInterfaceOrientations

返回 30(支持所有方向)

  1. iPad 模拟器是否旋转(物理上)?
  2. 如果是,我是否遗漏了什么?

0 个答案:

没有答案