关闭[使用自动布局"使应用程序只能运行在肖像模式 [英] Turning off "Use Autolayout" causes app to only run in portrait mode

查看:149
本文介绍了关闭[使用自动布局"使应用程序只能运行在肖像模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的应用程序将与iOS 5兼容,所以我不得不在XIB文件中禁用使用自动布局。整个应用程序被设计为横向模式下运行。当应用程序被停用自动布局(无论是在iOS 5中或iOS 6),应用程序启动总是在纵向模式并拒绝旋转为横向推出后。

在Info.plist中,支持的接口取向(新iPad)只能设置为横向。我究竟做错了什么?这只禁用自动布局后发生。


解决方案

我能够通过使用伊斯梅尔的回答来修复iOS 6中的问题。

   - (NSUInteger)supportedInterfaceOrientations {    返回UIInterfaceOrientationMaskLandscape;}

我可以使用下面的code修复它iOS 5中。

<$p$p><$c$c>-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {    返回UIInterfaceOrientationIsLandscape(toInterfaceOrientation);}

I want my app to be compatible with iOS 5, so I had to disable "Use Autolayout" in the XIB files. The whole app is designed to be run in landscape mode. When the app is launched after disabling autolayout (whether in iOS 5 or iOS 6), the app always launches in portrait mode and refuses to rotate to landscape.

In Info.plist, Supported Interface Orientations (iPad) is set only to landscape. What am I doing wrong? This only occurs after disabling autolayout.

解决方案

I was able to fix the issue in iOS 6 by using Ismael's answer.

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskLandscape;

}

I was able to fix it in iOS 5 by using the code below.

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {

    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);

}

这篇关于关闭[使用自动布局&QUOT;使应用程序只能运行在肖像模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆