Iphone UI设备方向未返回正确的值

Iphone UI设备方向未返回正确的值,iphone,Iphone,嘿,这是我正在使用的代码 switch ([[UIDevice currentDevice] orientation]) { case UIInterfaceOrientationPortrait: [self displayActionSheetInPotraitMode]; break; case UIInterfaceOrientationLandscapeL

嘿,这是我正在使用的代码

switch ([[UIDevice currentDevice] orientation]) 

        {
            case UIInterfaceOrientationPortrait:
                [self displayActionSheetInPotraitMode];
                break;
            case UIInterfaceOrientationLandscapeLeft:
            case UIInterfaceOrientationLandscapeRight:
                [self displayActionSheetInLandscapeMode];
                break;

            default:
                break;
        }
但是当我在iOS版本4或4.1的设备上尝试它时

开关([[UIDevice currentDevice]方向])

不返回正确的值。我的应用程序将在IOS 4之后运行。如何纠正此问题?

请查看此问题

或者试试看

UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
然后

switch(orientation)
干杯

看看这个

或者试试看

UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
然后

switch(orientation)
干杯