【问题标题】:The Device Orientation method is not working for ios6设备方向方法不适用于 ios6
【发布时间】:2012-12-28 10:38:04
【问题描述】:

我在 ios6 中支持横向和纵向模式。我也尝试了新的设备旋转方法,但是这些方法没有被调用并且它不支持方向。

我的代码如下:

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

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

我不知道这个问题。

谢谢...

【问题讨论】:

  • 检查目标支持的界面方向
  • 是的,它支持所有方向。
  • 检查supportedInterfaceOrientations和shouldAutorotate函数是否存在于所有类中..
  • 你在使用 UINavigationController 吗?
  • 是的,但使用拆分视图控制器

标签: iphone ios xcode orientation


【解决方案1】:

试试这个,

因为您提到:部署目标是 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

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

【讨论】:

  • 但在 ios6 中不调用 shouldAutorotate & supportedInterfaceOrientation
【解决方案2】:

你是否支持Info.plist中的Target中的所有Interface Orientations

您需要检查所有这些图像以支持所有Orientations

【讨论】:

  • 界面不自动旋转?你的目标是 iOS 6 还是 iOS 5?
  • 部署目标是 ios5 但我在 ios6 中运行应用程序
  • 你也试过 shouldAutorotateToInterfaceOrientation 方法(旧的)?
  • 是的,但在 ios6 中不调用 shouldAutorotateToInterfaceOrientation
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-24
  • 1970-01-01
相关资源
最近更新 更多