本文介绍了Modal View Controller无法正确旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ipad上的ios目标C中,我在一个模式视图中旋转移动遇到问题.我在shouldAutoRotate方法中给出了元素的位置,并且它的父视图也可以旋转,但是当我旋转模式视图时,元素没有放在正确的位置.

On the ipad, in ios objective C, I am having problems with the rotation moves in one modal view. I give the position of the element in the shouldAutoRotate method and its parent view can rotate too, but when I rotate the modal view the elements don't put in the correct place.

有关更多信息,如果我以纵向模式打开视图,则会得到以下数据:

For more information, if I open the view in portrait mode I get this data:

<UIView: 0x72bc160; frame = (0 0; 768 1004); clipsToBounds = YES;
autoresize = W+H; layer = <CALayer: 0x13f324f0>

在横向模式下:

<UIView: 0x1358f3b0; frame = (0 0; 768 748); clipsToBounds = YES;
autoresize = W+H; layer = <CALayer: 0x1358f3e0>>

但是如果我旋转视图,则水平框架会随垂直框架而变化...

But if I rotate the view the horizontal frame changes by vertical frame...

我做错什么了吗?

推荐答案

旋转视图控制器给我带来了很多乐趣.有两件事要记住:

I've had a lot of fun with view controller rotation. There are two things to keep in mind:

  1. 假设您覆盖了整个屏幕(并且对子视图转换不做任何特定的操作),请确保从尽可能广泛的视图控制器(通常是应用程序的根视图控制器)中呈现模态视图控制器. /li>
  2. 确保每个包含概念的视图控制器都将旋转事件传递给其概念子视图控制器. (这是在iOS 5之前的定义非常不明确).
  1. Assuming you're covering the entire screen (and don't do anything specific with subview transformation), make sure you are presenting the modal view controller from the broadest possible view controller, often the root view controller of the application.
  2. Make sure every conceptual containing view controller passes along the rotation events to its conceptual child view controllers. (This was very ill-defined pre-iOS 5.)

当这些事情发生在我身上时,是因为在后台的视图控制器收到了旋转事件,但是我所呈现的特定视图控制器却忽略了它们,而没有将它们传递给模态视图控制器,从而导致不一致

When these things happened to me, it was because the view controllers in the background got the rotation events, but the particular view controller I was presenting from was ignoring them and not passing them along to the modal view controller, leading to inconsistency.

这篇关于Modal View Controller无法正确旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 06:47