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?
基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01