Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm going to go ahead and disagree with @St3fan, and use <code>UIKit</code> as the counter-example.</p> <p><strong><em>However, the wisdom (or lack thereof), of embedding controllers in general should be guided by sane UI design principles.</em></strong></p> <p>The easiest counter-example is <code>UINavigationControllers</code> embedded in <code>UITabBarControllers</code>. These appear all over the place. Just off the top of my head, the iPod app on iPhone, and Contacts within the Phone app on iPhone.</p> <p>I was curious enough to bother to check what they do with the views (add to the "super-controller" view or to the <code>UIWindow</code>. I was pretty sure I was going to find that the sub-controller views were descendants of the super-controller views in the view hierarchy, which is contrary to St3fan's recommendation.</p> <p>I whipped up a very quick iPhone app hooking everything up in InterfaceBuilder to create a <code>UITabBarController</code> based app with two tabs, the first of which was a <code>UINavigationController</code> with a plain ole <code>UIViewController</code> as it's root view controller, and a 2nd tab with a plain old <code>UIViewController</code> just so I had a 2nd tab to click later.</p> <p>Sprinkle in some <code>NSLog</code> statements to output the various <code>UIView's</code> for the controllers we see this:</p> <pre><code>tabBarController.view = &lt;UILayoutContainerView: 0x5b0dc80; ... navigationController.view = &lt;UILayoutContainerView: 0x59469a0; ... rootViewController.view = &lt;UIView: 0x594bb70; ... Superview: &lt;UIViewControllerWrapperView: 0x594cc90; ... Superview: &lt;UINavigationTransitionView: 0x594a420; ... Superview: &lt;UILayoutContainerView: 0x59469a0; ... // navigationController.view Superview: &lt;UIViewControllerWrapperView: 0x594b430; ... Superview: &lt;UITransitionView: 0x5b0e110; ... Superview: &lt;UILayoutContainerView: 0x5b0dc80; ... // tabBarController.view Superview: &lt;UIWindow: 0x5942a30; ... </code></pre> <p>The lines prefixed with "Superview" were the output from walking up the <code>rootViewController.view's</code> superview chain until hitting nil.</p> <p>Then of course a quick glance at the call stack in a couple of places where <code>viewDidDisappear</code> would get called on the root view controller.</p> <p>First, the call stack when <code>viewDidDisappear</code> is called on the root controller as a result of a new controller being pushed on to the stack:</p> <pre><code>-[RootController viewDidDisappear:] -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] ... </code></pre> <p>Second, the call stack when another tab is selected in the top-most UITabBarController:</p> <pre><code>-[RootController viewDidDisappear:] -[UINavigationController viewDidDisappear:] -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] </code></pre> <p>So in all cases, it seems that Apple decided that controllers should be calling the various <code>viewDidAppear</code>, etc methods on their embedded subcontrollers and that the view's should be embedded similarly. I think the OP hit this nail right on the head if we're to take <code>UIKit</code> design as a good lead to follow.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload