允许一个视图支持多个方向,而其他人不要

编程入门 行业动态 更新时间:2024-10-11 09:28:50
本文介绍了允许一个视图支持多个方向,而其他人不要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个情况,其中我有多个视图通过 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.

更多推荐

允许一个视图支持多个方向,而其他人不要

本文发布于:2023-10-12 04:06:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483674.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   视图   而其   方向

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!