[英]view controller hierarchy and device orientation changes
When orientation changes occur and view controllers are subsequently notified of changes, does the entire of the root view and all its subviews receive these notifications? 当方向发生变化并随后将更改通知视图控制器时,整个根视图及其所有子视图是否都收到这些通知? I have created a root view and a subview to that root view.
我已经创建了一个根视图和该根视图的子视图。 Does the subview's controller (and any controllers of subviews in this hierarchy) receive all the rotation handling resulting from device orientation changes?
子视图的控制器(以及此层次结构中子视图的任何控制器)是否接收到由于设备方向更改而引起的所有旋转处理?
I ask because nested in this hierarchy is a UISplitViewController's view, and I suspect it is not receiving notification of device orientation changes. 我问,因为嵌套在此层次结构中的是UISplitViewController的视图,并且我怀疑它没有收到有关设备方向更改的通知。 ie I essentially have something like A -> B -> C in my view hierarchy where C is a UISplitViewController's view.
即,我的视图层次结构中基本上有A-> B-> C之类的东西,其中C是UISplitViewController的视图。
When orientation changes occur only the first view of the window will rotate together with its entire hierarchy. 当方向发生变化时,仅窗口的第一个视图将与其整个层次结构一起旋转。 In terms of viewControllers, the first view's viewController will get the orientation change events (and viewWill/DidAppear events) and all the viewControllers spawn by it.
就viewControllers而言,第一个视图的viewController将获取方向更改事件(以及viewWill / DidAppear事件),并由此产生所有viewControllers。 By spawn I mean a viewcontroller displayed using either as a tab of a uitabbarViewController, or added to a navigation controller, or displayed modally.
生成是指使用uitabbarViewController的选项卡显示或添加到导航控制器或以模态显示的Viewcontroller。 In other words if somewhere in your hierarchy you added a viewcontroller's view manually to the window or another view, that viewcontroller will not get any events.
换句话说,如果您在层次结构中的某个位置将视图控制器的视图手动添加到了窗口或其他视图,则该视图控制器将不会获得任何事件。
See this: why does viewDidAppear not get triggered? 看到这个: 为什么viewDidAppear没有被触发? same thing happens for orientations changes
方向改变也会发生同样的事情
So there are 2 possible causes: 因此,有两种可能的原因:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.