How can I display one UIView in landscape?(如何横向显示一个 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?


基础教程推荐
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01