你可以在iOS应用程序中全局禁用轮换吗? [英] Can you disable rotation globally in an iOS app?

查看:104
本文介绍了你可以在iOS应用程序中全局禁用轮换吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由很多视图控制器组成的应用程序...在项目摘要中我将Portrait方向设置为唯一受支持的设备方向。

I have an app made up of a lot of view controllers... in the project summary I've set Portrait orientation as the only supported device orientation.

然而,当转向侧面时,应用仍然会搞砸。

However, the app still gets messed up when turned sideways.

我的问题是,有没有办法通过app delegate全局禁用自动旋转?

My question is, is there a way to globally disable autorotation through app delegate or something?

或者我是否必须进入所有视图控制器并添加shouldAutorotateToInterfaceOrientation方法?

Or do I have to go into all of my view controllers and add the "shouldAutorotateToInterfaceOrientation" method?

只是不想要错过将其添加到一个或多个... ...

Just don't want to miss adding it to one or something...

谢谢!

推荐答案

在根视图控制器的方法中:

in root view controller's method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

设置'返回NO';

这应该适用于所有视图。

this should do for all the Views.

这篇关于你可以在iOS应用程序中全局禁用轮换吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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