iPhone开发中的错误定位

iPhone开发中的错误定位,iphone,objective-c,xcode,ipad,Iphone,Objective C,Xcode,Ipad,我已经为iPhone和iPad开发了一个通用应用程序。 使用Targets中的“Supported interface orientations”选项(在Xcode项目中),我已经设置了所需的配置,一个用于iPhone,另一个用于iPad。 iPhone(5.1和6.1)没有问题,但对于iPad,我发现5.1固件的方向不正确(不像以前写的那样设置)。对于配备iOS 6.1的iPad,该应用程序工作正常 我已经阅读了另一个stackoverflow的问题,并给出了解决方案:通过引入以下代码,问题将

我已经为iPhone和iPad开发了一个通用应用程序。 使用Targets中的“Supported interface orientations”选项(在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;
}
就我而言,问题仍然存在。我该怎么办

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return toInterfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
在您的例子中,上面的方法总是返回YES(int大于0),这样它将为所有其他接口方向返回no

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