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?
- Android - 拆分 Drawable 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01