简体   繁体   English

Modal View Controller无法正确旋转

[英]Modal View Controller don't rotate correctly

On the ipad, in ios objective C, I am having problems with the rotation moves in one modal view. 在ipad的ipad上,在ios目标C中,我在一种模式视图中遇到了旋转移动的问题。 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. 我在shouldAutoRotate方法中给出了元素的位置,并且它的父视图也可以旋转,但是当我旋转模式视图时,元素没有放在正确的位置。

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>

And in landscape mode: 在横向模式下:

<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... 但是如果我旋转视图,则水平框架会随垂直框架而变化...

Am I doing something wrong? 难道我做错了什么?

I've had a lot of fun with view controller rotation. 视图控制器旋转给我带来了很多乐趣。 There are two things to keep in mind: 有两件事要牢记:

  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.) (这是在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. 当这些事情发生在我身上时,是因为在后台的视图控制器收到了旋转事件,但是我要呈现的特定视图控制器却忽略了它们,而没有将它们传递给模态视图控制器,从而导致了不一致。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM