简体   繁体   English

设备旋转后设置前一个视图控制器的布局

[英]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之后,我尝试在viewWillAppearviewDidLoad更新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. 如果我在viewDidAppearviewWillLayoutSubviews执行它,它会起作用,但它仅在视图出现后更新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 . 到目前为止我找到的唯一解决方案是我在我的问题中提到的解决方案,我在viewDidAppearviewWillLayoutSubviews更新了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.

相关问题 在设备旋转时更改视图控制器 - Change view controller on device rotation 显示模式视图控制器时设备旋转 - Device rotation while displaying modal view controller 在视图控制器上旋转设备时崩溃 - Crash during device rotation on a view controller Swift:Collection在旋转后查看更改布局 - Swift: Collection View changing layout after rotation 旋转设备后视图变暗和变形 - Squashed and distorted view after device rotation 旋转后iOS视图控制器移位 - iOS View Controller Shifts After Rotation iOS8 - 在UINavigationController上推送UIViewController并旋转设备后,以前的视图控制器中的大小错误 - iOS8 - After pushing a UIViewController on a UINavigationController and rotating the device, the size is wrong in previous view controller iPhone如何响应设备旋转显示不同的视图控制器? - iPhone how to display a different view controller in response to device rotation? Swift:如何在设备旋转后刷新 UICollectionView 布局 - Swift: How to refresh UICollectionView layout after rotation of the device 以编程方式将UIBarButtonItem目标设置为上一个视图控制器 - Set UIBarButtonItem target programmatically to previous view Controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM