大佬教程收集整理的这篇文章主要介绍了在iOS中模拟方向更改以进行测试,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我不在乎它是否是一些未记录的私有API或黑客,因为这只会在测试期间运行,并且不会成为生产构建的一部分.
+ (KIFTestSteP*) stepToInterfaceOrientation: (UIInterfaceOrientation) toInterfaceOrientation { NSString* orientation = UIInterfaceOrientationIsLandscape(toInterfaceOrientation) ? @"Landscape" : @"PorTrait"; return [KIFTestStep stepWithDescription: [NSString StringWithFormat: @"Rotate to orientation %@",orientation] executionBlock: ^KIFTestStepResult(KIFTestStep *step,NSError *__autoreleasing *error) { if( [UIApplication sharedApplication].statusBarOrientation != toInterfaceOrientation ) { UIDevice* device = [UIDevice currentDevice]; SEL message = NSSELEctorFromString(@"setOrientation:"); if( [device respondsToSELEctor: message] ) { NSMethodSignature* signature = [UIDevice instanceMethodSignatureForSELEctor: message]; NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: signature]; [invocation setTarget: device]; [invocation setSELEctor: message]; [invocation setArgument: &toInterfaceOrientation aTindex: 2]; [invocation invoke]; } } return KIFTestStepResultsuccess; }]; }
注意:将设备平放在桌面上,或者加速度计更新会将视图旋转回来.
以上是大佬教程为你收集整理的在iOS中模拟方向更改以进行测试全部内容,希望文章能够帮你解决在iOS中模拟方向更改以进行测试所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。