iOS 8在应用程序启动时检测设备方向

时间:2014-09-02 07:20:21

标签: ios iphone orientation ios8

方法[[UIDevice currentDevice] orientation]在应用程序启动时没有返回正确的值。这是一个API测试版错误,还是有一种新的方法来检测iOS 8中的方向?

这是在应用程序启动时使用的确切代码。

UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];

if (deviceOrientation == UIDeviceOrientationPortrait){
}
else if (deviceOrientation == UIDeviceOrientationLandscapeLeft){
    [self orientationLandscapeLeftAdjust];
}
else if (deviceOrientation == UIDeviceOrientationLandscapeRight){
    [self orientationLandscapeRightAdjust];
}
else if (deviceOrientation == UIDeviceOrientationPortraitUpsideDown){
    [self orientationPortraitUpSideDownAdjust];
}

1 个答案:

答案 0 :(得分:1)

事实证明,这是一个与每次在iOS 8 beta 5中启动应用程序时弹出的“无SIM卡”警告消息相关的错误。这会强制应用程序以默认方向启动。我读到这个bug已经在iOS 8 beta 6中得到解决,它已经分发给运营商和其他测试合作伙伴。