不能将UIViewController限制为纵向 [英] Can't restrict UIViewController to Portrait only

查看:48
本文介绍了不能将UIViewController限制为纵向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的应用程序嵌入到 UINavigationController 中,我希望我的大多数 ViewControllers 除了是Portrait,我已经阅读了很多问题,但无法找到适合我的正确答案.

I'm embedding my app in a UINavigationController, I want most of myViewControllers except one to be Portrait, I've read a lot of questions but could not find a correct answer that works for me.

在目标中,我选择 Device Orientation : Portrait Landscape Right

In my target I'm selecting Device Orientation : Portrait, Landscape Right

我将其添加到我的第一个ViewController中:

I'm adding this to my first ViewController:

-(BOOL)shouldAutorotate{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations{
    return (UIInterfaceOrientationPortrait);
}

但是当我旋转设备时,ViewController也会旋转.为什么旋转?

But when I rotate the device left the ViewController rotates as well. Why is it rotating?

推荐答案

您很难在iOS 7中完成您要描述的内容.UINavigationController不会就其喜欢的旋转方式咨询其子级;无论UINavigationController允许的旋转角度如何,这些都是应用程序的允许旋转角度,而不管那个时刻恰好显示哪个子级.

You can't easily do in iOS 7 what you're describing. A UINavigationController does not consult its children as to what rotations they like; whatever the permitted rotations of the UINavigationController, those are the permitted rotations of the app, regardless of which child happens to be showing at that moment.

强制旋转的唯一真正合法且内置的方法是使用显示的(模态")视图控制器来接管屏幕.由于现在由屏幕负责,因此请咨询其旋转设置.

The only really legal and built-in way to force rotation is to use a presented ("modal") view controller that takes over the screen. Its rotation settings are consulted because it is now in charge of the screen.

这篇关于不能将UIViewController限制为纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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