Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios iphone4和iphone5的设备定位不同?_Ios_Iphone_Objective C_Device Orientation - Fatal编程技术网

Ios iphone4和iphone5的设备定位不同?

Ios iphone4和iphone5的设备定位不同?,ios,iphone,objective-c,device-orientation,Ios,Iphone,Objective C,Device Orientation,我已经编写了一个应用程序,它的一个用例会对设备方向做出反应。在我的iPhone5上一切正常,但在我的测试人员iPhone4上什么也没发生 我正在使用试飞检查点检查它们是否达到翻转方法,这意味着([[UIDevice currentDevice]orientation])在不同的iPhone版本中返回不同的值,或者我需要检查其他设备是否处于横向模式 -(BOOL)checkDeviceOrientation { BOOL orientationError = NO; switch

我已经编写了一个应用程序,它的一个用例会对设备方向做出反应。在我的iPhone5上一切正常,但在我的测试人员iPhone4上什么也没发生

我正在使用试飞检查点检查它们是否达到翻转方法,这意味着
([[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;
}

有人遇到过同样的问题吗?有什么建议吗

根据我的经验,最好检查状态栏方向,而不是设备方向。设备方向是物理设备的方向,而不是UI的方向

[UIApplication sharedApplication].statusBarOrientation

另外,您可能会遇到这样的情况:设备是
UIDeviceOrientationFaceUp
UIDeviceOrientationFaceDown

您在哪里检查方向?两台设备是否运行同一版本的iOS?@nhgri如果两台设备运行同一版本的iOS,并且我检查了在按钮上调用的方法的方向,请单击相关代码。@Lance([[UIDevice currentDevice]orientation]上没有任何特殊的开关盒)在左右横向中,我有一个警报。这是在特定的视图控制器或应用程序级别内吗?我需要物理设备的方向,即用户手持手机的实际方式。我面临的问题是,在iPhone5中,我得到了正确的值,而在iPhone4中,我总是得到纵向。哦,明白了。是的,这毫无意义。你确定这都是iPhone4的吗?还是这部手机有问题?加速计是否有损坏/禁用的可能(可能是旋转锁?)