如何在iOS中锁定屏幕使其仅具有纵向方向? [英] How lock screen in iOS for it to have only portrait orientation?

查看:180
本文介绍了如何在iOS中锁定屏幕使其仅具有纵向方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个具有很多视图的应用程序,我只想将其中一些视图设为纵向. 我已经在.m文件中对此进行了编码:

I have created an app with many views and I want to have some of them only in portrait orientation. I have coded this in .m file:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return NO;
}

我还需要做其他事情吗?可能在.h文件中?

Do I need to do something else? May be in .h file?

推荐答案

对我而言最干净的解决方案:

Cleanest solution for me:

转到Info.plist文件,对于支持的界面方向",删除除纵向(底部主页按钮)"以外的所有值.

Go to Info.plist file and for the "Supported interface orientations", remove every value except "Portrait (bottom home button)".

这篇关于如何在iOS中锁定屏幕使其仅具有纵向方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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