iPhone开发中的方向不正确

时间:2013-04-11 17:43:58

标签: iphone objective-c xcode ipad

我开发了适用于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;
}

就我而言,问题仍然存在。我该怎么办?

1 个答案:

答案 0 :(得分:1)

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

在你的情况下,上面的方法总是返回YES(int大于0),这样它将为所有其他接口方向返回no。

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