仅为Swift中的测试运行代码

时间:2018-01-18 07:31:24

标签: ios swift xcode

我希望在使用任何测试时将相机屏幕旋转到左侧,否则将其保持为rotateRight。

以下是主架构代码

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

但我想在使用此

的测试架构时将其更改为landscapeLeft

指出我保持一定条件的正确方向。

我使用的是Swift 4,Xcode 9.2。

1 个答案:

答案 0 :(得分:0)

假设这是一个UI测试,您应该能够在测试方法的顶部执行以下操作:

XCUIDevice.shared().orientation = .landscapeLeft