Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This part is not correct:</p> <pre><code>[vc willMoveToParentViewController:self]; [self addChildViewController:vc]; [self.view addSubview:vc.view]; // or something like this. [vc didMoveToParentViewController:self]; </code></pre> <p><a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/willMoveToParentViewController:" rel="noreferrer">According to the docs:</a></p> <blockquote> <p>When your custom container calls the addChildViewController: method, it automatically calls the willMoveToParentViewController: method of the view controller to be added as a child before adding it.</p> </blockquote> <p>So you don't need the <code>[vc willMoveToParentViewController:self]</code> call. It is done automatically when you call <code>[self addChildViewController:vc]</code>. Here's the code sample again:</p> <pre><code>[self addChildViewController:vc]; // [vc willMoveToParentViewController:self] called automatically [self.view addSubview:vc.view]; // or something like this. [vc didMoveToParentViewController:self]; </code></pre> <p><a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/didMoveToParentViewController:" rel="noreferrer">For removing view controllers:</a></p> <blockquote> <p>The removeFromParentViewController method automatically calls the didMoveToParentViewController: method of the child view controller after it removes the child.</p> </blockquote> <p>Presumably this call is <code>[oldVC didMoveToParentViewController:nil]</code>.</p> <pre><code>[vc willMoveToParentViewController:nil]; [vc.view removeFromSuperview]; [vc removeFromParentViewController]; // [vc didMoveToParentViewController:nil] called automatically </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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.
    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