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

3

在应用启动时,方法[[UIDevice currentDevice] orientation]没有返回正确的值。这是API beta版本的错误还是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个回答

1
原来这是与iOS 8 beta 5中每次启动应用程序都会弹出“无SIM卡”警报消息相关的错误。这将强制应用程序以其默认方向启动。我读到这个错误已经在分发给运营商和其他测试伙伴的iOS 8 beta 6中得到解决。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接