简体   繁体   中英

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. ie I essentially have something like A -> B -> C in my view hierarchy where C is a UISplitViewController's view.

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. By spawn I mean a viewcontroller displayed using either as a tab of a uitabbarViewController, or added to a navigation controller, or displayed modally. 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? same thing happens for orientations changes

So there are 2 possible causes:

  • your uisplitviewController's view or any of its parent is added manually to the view hierarchy instead of pushing the viewcontroller (the view gets rotated but does not receive events)
  • you added the view as a second child of the window (the view doesn't get rotated at all)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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