如何在横向中显示一个UIView? [英] How can I display one UIView in landscape?

查看:102
本文介绍了如何在横向中显示一个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对于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.

推荐答案

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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