允许一个视图支持多个方向,而其他人不要 [英] Allow One View to Support Multiple Orientations While Others Do Not iPhone

查看:98
本文介绍了允许一个视图支持多个方向,而其他人不要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个情况,其中我有多个视图通过 UITabBarController 控制。其中一个视图通过 UINavigationController 控制。应用程序应该只支持纵向的所有视图...除了一个单独的视图。这个视图被推到导航控制器的堆栈,应该允许纵向和横向。

I have a situation where I have multiple views controlled via UITabBarController. One of those views is controlled via a UINavigationController. The application should only support Portrait for all views... except one single solitary view. This view is pushed onto the stack of the navigation controller and should allow both portrait AND landscape.

我尝试了每个解决方案,我想到的,但是,解决方案只是不工作或更糟的是完全不可预测。

I've tried every solution that I can think of but, either the solution just doesn't work or worse is completely unpredictable.

有人以干净的方式解决了这个问题吗?

Has anybody solved this issue in a clean way?

推荐答案

您使用 presentModalViewController pushViewController 呈现的视图控制器应该支持任何方向,使用此方法:

The view's controller that you present either using presentModalViewController OR pushViewController should support any orientation, using this method:

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

使用这种方法,当您以横向显示控制器时,也以横向方向显示。

With this method, when you present your controller in landscape orientation, it will correctly appear in landscape orientation, too.

这篇关于允许一个视图支持多个方向,而其他人不要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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