关闭"使用Autolayout"会导致应用仅以纵向模式运行

Jac*_*ies 1 objective-c xib ipad ios autolayout

我希望我的应用程序与iOS 5兼容,因此我不得不在XIB文件中禁用"使用Autolayout".整个应用程序旨在以横向模式运行.在禁用自动布局后启动应用程序时(无论是在iOS 5还是iOS 6中),应用程序始终以纵向模式启动并拒绝旋转到横向.

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

Jac*_*ies 5

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

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskLandscape;

}
Run Code Online (Sandbox Code Playgroud)

我可以使用下面的代码在iOS 5中修复它.

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);

}
Run Code Online (Sandbox Code Playgroud)