iPhone旋转力 [英] iPhone force rotation

查看:57
本文介绍了iPhone旋转力的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在旋转阅读大量信息,但是没有找到查询的解决方案.去吧:

I have been reading a ton on rotation, but not finding a solution to my query. Here goes:

我有一个带有标签栏的肖像应用程序,并且标签中有隐藏的导航控制器.在应用程序中的某个位置,下一个视图必须是横向视图.

I have a portrait application with a tabbar and hidden navigation controller in my tab. At a point in the app, the next view must be landscape.

XIB布局是在横向上完成的,因此我想调出xib时不要使用任何翻译或像素移动代码.(不认为这是必需的).我尝试过仅推动视图(保持纵向),使用各种方法移动视图(似乎无法正确对齐).

The XIB layout has been done in landscape, so I want to bring up the xib without any translation or pixel moving code. (not thinking this is required) I have tried just pushing the view (remains in portrait), shifting the view using various methods (non seem to line thing up properly).

有没有办法告诉视图在打开之前已经将其放置在景观中?

Is there a way to tell the view that it is already laid out for landscape prior to it being opened?

提前谢谢!

推荐答案

我很肯定您不能强制"轮换.系统决定何时更改设备的方向.因此方向"属性本质上是只读的.很久以前,当我想确保始终以一个方向显示特定视图时,我就曾遇到过同样的问题.

I'm positive that you cannot 'force' a rotation. The system decides when to change the orientation of the device; so the 'orientation' properties are essentially read-only. I looked into this same problem a long time ago when I wanted to make sure a particular view always displayed in one orientation.

由于此,大多数应用程序允许其所有视图和视图控制器以应用程序支持的任何方向工作.我发现试图限制某些视图和视图控制器的行为最终会带来更多麻烦,并且可能会在视图和视图控制器之间转换时引起问题.

Due to this, most apps allow all of their views and view controllers to work in any of the orientations the app supports. I've found that trying to restrict the behavior of some views and view controllers ultimately creates more hassle, and can cause issues when transitioning between views and view controllers.

您发布的代码将适用于您的视图.您实际上根本没有改变方向;您的视图的行为就像是通过以旋转方式进行绘制来旋转一样.我不确定是否可以对导航栏执行相同的操作,但这值得一试.如果您能够控制导航栏的视图属性(它也是一个UIView),则可以应用与自定义视图相同的模式.

The code you posted will work for your view. You are not actually changing the orientation at all; your view is just behaving like it has been rotated by drawing in a rotated fashion. I'm not sure if you can do the same thing to the navigation bar or not, but it's worth a shot. If you are able to control the view properties of the navigation bar (it is a UIView as well), applying the same pattern you are using for your custom view should work.

大多数只希望视图处于风景中的应用最终会迫使其整个应用都处于风景中.例如,飞行控制仅支持一种方向.因此,绘图代码非常简单.无论方向如何,只需绘制视图并将其旋转到它支持的一个方向(左或右横向)即可.

Most apps that want a view to only be in landscape ultimately force their entire app to be in landscape. For instance, Flight Control only supports one orientation. Thus, the drawing code is pretty simple; regardless of orientation, just draw the view and rotate it to the one orientation it supports (either landscape left or right).

您的应用程序设计并非如此简单……听起来好像您不是在设计全屏应用程序.您将不得不担心导航栏和状态栏的绘制正确.

Your app's design wouldn't be that easy... it sounds like you are not designing a full-screen app. You would have to worry about the navigation bar and status bar being properly drawn.

这篇关于iPhone旋转力的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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