0

我为 iPhone 和 iPad 开发了一个通用应用程序。使用 Targets 中的“支持的界面方向”选项(在 Xcode 项目中),我设置了所需的配置,一个用于 iPhone,另一个用于 iPad。iPhone(5.1 和 6.1)没有问题,但在 iPad 上,我看到 5.1 固件中的方向不正确(不像之前写的那样设置)。对于装有 iOS 6.1 的 iPad,该应用程序可以正常工作。

我已经阅读了另一个 stackoverflow 的问题,有一个解决方案:引入以下代码,问题将是正确的。

-(NSInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationLandscapeRight;
}
// pre-iOS 6 support
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationLandscapeRight;
}

就我而言,问题仍然存在。我能怎么做?

4

1 回答 1

1
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return toInterfaceOrientation == UIInterfaceOrientationLandscapeRight;
}

在您的情况下,上述方法始终返回 YES(大于 0 的 int),这样对于所有其他界面方向,它将返回 no。

您可能希望重构代码以支持两种横向方向,但将视图锁定为仅一种横向方向是一种不好的做法。

于 2013-04-11T17:48:40.123 回答