我已经编写了一个应用程序,其中一个用例会对设备方向做出反应。在我的iPhone 5上一切正常,但在我的测试人员iPhone 4上没有任何反应。
我正在使用测试飞行检查点,看他们没有达到翻转方法,这意味着([[UIDevice currentDevice] orientation])
要么在不同的iPhone版本中返回不同的值,要么我需要检查其他内容以查看是否设备处于横向模式。
-(BOOL)checkDeviceOrientation
{
BOOL orientationError = NO;
switch ([[UIDevice currentDevice] orientation])
{
case UIDeviceOrientationPortraitUpsideDown:
case UIDeviceOrientationLandscapeLeft:
case UIDeviceOrientationLandscapeRight:
[self setRotationMessage:[[UIDevice currentDevice] orientation]];
orientationError = YES;
break;
default:
break;
}
return orientationError;
}
有没有人遇到同样的问题,有什么建议吗?
答案 0 :(得分:0)
根据我的经验,最好检查状态栏方向而不是设备方向。设备方向是物理设备的方向,而不是UI。
[UIApplication sharedApplication].statusBarOrientation
顺便说一句,您可能遇到设备为UIDeviceOrientationFaceUp
或UIDeviceOrientationFaceDown