如何横向显示一个 UIView?

How can I display one UIView in landscape?(如何横向显示一个 UIView?)

本文介绍了如何横向显示一个 UIView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我已经查看了所有问题,但似乎没有人真正回答这个问题.

I've looked at every question so far and none seem to actually answer this question.

我创建了一个 UITabBarController 并向其中添加了几个视图控制器.大多数视图都是纵向查看的,但应该以横向查看.我不想使用加速度计或检测用户何时旋转设备,我只想在他们从底部选项卡中选择视图时以横向模式显示视图.

I created a UITabBarController and added several view controllers to it. Most of the views are viewed in portrait, but one should be viewed in landscape. I don't want to use the accelerometer or detect when the user rotates the device, I just want to display the view in landscape mode when they choose that view from the tab at the bottom.

我希望在他们选择该项目时发生常规动画,例如选项卡退出、视图旋转等,而当他们选择不同视图时发生相反的情况.

I want the regular animations to occur, such as the tab dropping out, the view rotating, etc., when they choose that item, and the opposite to happen when they choose a different view.

是否没有内置的属性或方法来告诉系统将视图显示为什么方向?

Is there not a built-in property or method to tell the system what orientation to display the view as?

据我所知,重写 shouldautorotate... 方法绝对没有任何作用.

Overriding the shouldautorotate... method does absolutely nothing so far as I can tell.

我不喜欢的答案类型是RTFM",因为我已经有了,而且到目前为止为 iPhone 开发的任何人都知道几乎没有有用的 M 到 F-ing R.

The type of answer I would NOT appreciate is "RTFM" because I already have, and anybody who's developed for the iPhone so far knows that there is very little useful M to F-ing R.

推荐答案

一个在可能有帮助的论坛上发帖.简短的回答是,一旦视图被绘制,您必须在 viewWillAppear: 方法中手动旋转视图或控制器

An post on a forum that might help. Short answer is you have to manually rotate your view or controller once the view has been drawn, in the viewWillAppear: method

CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90));
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +100.0);

[[appDelegate navController].view setTransform:landscapeTransform];

这篇关于如何横向显示一个 UIView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何横向显示一个 UIView?

基础教程推荐