我正在尝试使用XCTestCase在不同方向上测试我的iOS应用。我需要一种以编程方式更改方向的方法。我尝试使用2种方法进行此操作,但两种方法均未更改方向(方向仍为UIInterfaceOrientationPortrait)。
尝试1
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft;`
Run Code Online (Sandbox Code Playgroud)
尝试2
[[UIDevice currentDevice] setValue:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft] forKey:@"orientation"];`
Run Code Online (Sandbox Code Playgroud)
当我阅读[[UIApplication sharedApplication] statusBarOrientation]时,是否还有另一种方法可以更改方向以进行测试?