强制UIViewController仅以横向模式显示 [英] Force UIViewController to only show in landscape mode

查看:152
本文介绍了强制UIViewController仅以横向模式显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序以纵向模式运行,但我想以横向模式显示一个屏幕,因为它是一个图表。我将如何添加到我的uiviewcontroller以强制它进入横向模式?

My app runs in portrait mode, but i want to show one screen in landscape mode only as it is a chart. What do i add to my uiviewcontroller to force it into landscape mode only?

推荐答案

对不起,这个回答非常好简短:如果您正在使用UINavigationController,则不能。 @jer给出的答案是错误的。 Apple文档声明:

I'm sorry but this answer will be very short: If you're using the UINavigationController, you can't. The answer @jer gives is therefore incorrect. The Apple documentation states:


UITabBarController或UINavigationController中的所有子视图控制器都不同意公共方向集。

All child view controllers in your UITabBarController or UINavigationController do not agree on a common orientation set.

我最近在赏金上回答了这个问题,我的应用程序在此过程中被拒绝了。请阅读此处:如何将自动旋转限制为某些视图的单一方向,同时允许其他方向的所有方向?

I recently had this question answered on a bounty and my app rejected in the process. Read up on that here: How to constrain autorotation to a single orientation for some views, while allowing all orientations on others?

你唯一的解决办法是抛弃UINavigationController并用你自己的东西重写它。

The only solution you have, is to throw away the UINavigationController and rewrite it with something of your own.

这篇关于强制UIViewController仅以横向模式显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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