[英]Set layout of previous view controller after device rotation
I have a UIViewController
vc2
which is on the navigation stack after vc1
. 我有一个
UIViewController
vc2
,它位于vc1
之后的导航堆栈上。 When I rotate the device while on vc2
, I need vc1
to also update its UI. 当我在
vc2
上旋转设备时,我需要vc1
来更新它的UI。 However when I try and do this in willAnimateRotationToInterfaceOrientation
it doesn't work. 但是,当我尝试在
willAnimateRotationToInterfaceOrientation
执行此操作时,它不起作用。
After I pop vc2
off of the stack, I try to update vc1
UI in viewWillAppear
or viewDidLoad
but it doesn't work. 在我从堆栈弹出
vc2
之后,我尝试在viewWillAppear
或viewDidLoad
更新vc1
UI,但它不起作用。 It works if I do it in viewDidAppear
or viewWillLayoutSubviews
, but it updates the UI only after the view appears so the user can see it animating on the screen. 如果我在
viewDidAppear
或viewWillLayoutSubviews
执行它,它会起作用,但它仅在视图出现后更新UI,以便用户可以在屏幕上看到它的动画。
Is there a way to set it before the view appears so the user doesn't see the subviews animating? 有没有办法在视图出现之前设置它,以便用户看不到子视图动画?
The only solution I've found to work so far is the one I mentioned in my question where I update the UI in viewDidAppear
or viewWillLayoutSubviews
. 到目前为止我找到的唯一解决方案是我在我的问题中提到的解决方案,我在
viewDidAppear
或viewWillLayoutSubviews
更新了UI。 Unfortunately, you'll see your UI components animate to the proper position on screen when the view controller appears. 不幸的是,当视图控制器出现时,您会看到UI组件在屏幕上显示正确的位置。 Hopefully someone can find a better solution.
希望有人能找到更好的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.