Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In iOS 4 and before, you are not supposed to create your own UIViewController hierarchy, so you have to manipulate views <em>directly</em> as subviews of a UIViewController's view.</p> <p>However, if you do this correctly, there <em>is</em> still a UIViewController hierarchy and it does still work. There is no circumstance in which you "do not have a reference" to the UINavigationController. A view has a superview, which is another view. A UIViewController's view has a reference to the UIViewController (as its <code>nextResponder</code>). The UIViewController has a reference to its parent UINavigationController if there is one.</p> <p>If that's not the case, you're doing something very wrong with view controllers.</p> <p>Apple's documentation says this (for iOS 4 and before), and you should take it very seriously:</p> <blockquote> <p>You should not use multiple custom view controllers to manage different portions of the same view hierarchy. ... If you want to divide a view hierarchy into multiple subareas and manage each one separately, use generic controller objects (custom objects descending from NSObject) instead of view controller objects to manage each subarea. Then use a single view controller object to manage the generic controller objects.</p> </blockquote> <p>The rule in iOS 4 <em>and later</em> remains the same: do not use a UIViewController except as part of a legitimate UIViewController hierarchy, where the view controller's view is in <em>exactly the same</em> hierarchy, as in this diagram from my book:</p> <p><img src="https://i.stack.imgur.com/qNXRA.png" alt="enter image description here"></p> <p>Observe that the view controllers are parent and child <em>and</em> that their views are superview and subview. That is how to use a view controller hierarchy. If you're doing things in iOS 4 that would violate this, don't. Use views but <em>not</em> view controllers.</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.
 

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