设备方向方法不适用于ios6

时间:2012-12-28 10:38:05

标签: iphone ios xcode orientation

我支持Landscape& ios6中的纵向模式。我也尝试使用新的设备旋转方法,但这些方法并没有被称为&它不支持方向。

我的代码如下:

-(NSUInteger)supportedInterfaceOrientations
{
    NSLog(@"supportedInterfaceOrientations...");
    return UIInterfaceOrientationMaskAll;
}

-(BOOL)shouldAutorotate
{
    NSLog(@"shouldAutoRotate...");
    return YES;
}

我不知道这个问题。

...谢谢

2 个答案:

答案 0 :(得分:0)

您是否在Info.plist

中分别支持目标中的所有界面方向

Supported Interface Orientations 您需要检查所有这些图片以支持所有Orientations

答案 1 :(得分:0)

试试这个,

因为您提到:部署目标是ios5,但您在ios6中运行应用程序。

在.pch文件中,

#define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0 )

#define IOS_NEWER_OR_EQUAL_TO_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0 )

在控制器文件中,检查条件,

#ifdef IOS_OLDER_THAN_6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
     return toInterfaceOrientation;
}
#endif

#ifdef IOS_NEWER_OR_EQUAL_TO_6
-(BOOL)shouldAutorotate {
     return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
     return (UIInterfaceOrientationMaskAll);
}
#endif

希望对您有所帮助。 感谢。