【发布时间】:2014-01-27 23:44:14
【问题描述】:
我编写了一个应用程序,其中一个用例对设备方向做出反应。在我的 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;
}
有没有人遇到过同样的问题,有什么建议吗?
【问题讨论】:
-
你在哪里检查方向?两台设备是否运行相同版本的 iOS?
-
@nhgrif 两个设备都运行相同的 ios 版本,我检查按钮单击时调用的方法内的方向
-
请提供相关代码。
-
@Lance 没什么特别的,左右横向 ([[UIDevice currentDevice] 方向]) 上的开关盒我有一个警报。
-
这是在特定的视图控制器或应用程序级别内吗?
标签: ios iphone objective-c device-orientation