closures“使用Autolayout”导致应用程序只能在纵向模式下运行

我想我的应用程序与iOS 5兼容,所以我必须在XIB文件中禁用“使用Autolayout”。 整个应用程序被devise为在横向模式下运行。 当禁用自动布局(无论是在iOS 5还是iOS 6)启动应用程序时,应用程序始终以纵向模式启动,并拒绝旋转为横向。

在Info.plist中, Supported Interface Orientations (iPad)仅被设置为横向。 我究竟做错了什么? 这仅在禁用自动布局之后才会发生。

我能够通过使用Ismael的答案解决iOS 6中的问题。

 - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } 

我能够通过使用下面的代码在iOS 5中修复它。

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

添加到您的控制器:

 - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } 

编辑:如果你不想支持肖像,你应该在shouldAutorotate返回NO