2013-04-11 61 views
0

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

我读过另一个stackoverflow的问题的解决方案:问题将是正确的,引入下面的代码。

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

在我的情况下,问题仍然存在。我能怎么做?

回答

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

上述方法在你的情况总是返回YES(INT大于0),这样,将不返回所有其它接口的方向。

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