方向改变,我的所有视图控制器什么时候旋转?
如果我有多个 UIViewController 被推送到我的导航堆栈上,那么如何/何时重新布局不可见(底部)视图控制器?它们是与可见视图控制器同时布局,还是仅在弹出到显示堆栈时布局?
编辑: 我目前自己管理调整子视图的大小(而不是设置 autoresizing=YES)。我在 willAnimateRotationToInterfaceOrientation 方法中调整大小,以便它的动画效果很好。我猜想任何不在显示堆栈顶部的 uiviewcontroller 都不会调用此方法。那么有没有一种内置方法可以知道当前的 uiviewcontroller 是否是正在显示的,如果不是,我应该重写哪个方法来重新布局不在显示堆栈顶部的 uiviewcontroller 的子视图?
谢谢!
阳光明媚
If I have several UIViewControllers pushed onto my navigation stack, how/when are the none-visible (bottom) view controllers re-layed-out? Do they all get layed-out at the same time as the visible view controller, or only once they are popped onto the display stack?
edit:
I currently manage resizing subviews myself (rather than setting autoresizing=YES). I do my resizing in the willAnimateRotationToInterfaceOrientation method, so that it is all animated nicely. I'm guessing this method doesn't get called for any uiviewcontroller not on top of the display stack. So is there a built-in way to know if the current uiviewcontroller is the one being displayed, and if it isn't, which method should I override to relayout my subviews for the uiviewcontrollers that aren't at the top of the display stack?
Thanks!
Sunny
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议检查
viewWillAppear
中的方向。如果您在此处检查方向,则可以放心,视图将始终以给定方向的正确布局显示。不过,您仍然需要在willAnimateRotationToInterfaceOrientation
中旋转它。I would suggest checking the orientation in
viewWillAppear
. If you check the orientation here, you can be assured that a view will always appear with the correct layout for a given orientation. You still need to rotate it inwillAnimateRotationToInterfaceOrientation
though.