Created
November 30, 2011 20:54
-
-
Save peterfriese/1410770 to your computer and use it in GitHub Desktop.
Do I need to call didMoveToParentViewController in my custom container view controller? Yes, you do, the doc says it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Taken from UIViewController.h, code is (c) Apple | |
/* | |
These two methods are public for container subclasses to call when transitioning between child | |
controllers. If they are overridden, the overrides should ensure to call the super. The parent argument in | |
both of these methods is nil when a child is being removed from its parent; otherwise it is equal to the new | |
parent view controller. | |
addChildViewController: will call [child willMoveToParentViewController:self] before adding the | |
child. However, it will not call didMoveToParentViewController:. It is expected that a container view | |
controller subclass will make this call after a transition to the new child has completed or, in the | |
case of no transition, immediately after the call to addChildViewController:. Similarly | |
removeFromParentViewController: does not call [self willMoveToParentViewController:nil] before removing the | |
child. This is also the responsibilty of the container subclass. Container subclasses will typically define | |
a method that transitions to a new child by first calling addChildViewController:, then executing a | |
transition which will add the new child's view into the view hierarchy of its parent, and finally will call | |
didMoveToParentViewController:. Similarly, subclasses will typically define a method that removes a child in | |
the reverse manner by first calling [child willMoveToParentViewController:nil]. | |
*/ | |
- (void)willMoveToParentViewController:(UIViewController *)parent __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0); | |
- (void)didMoveToParentViewController:(UIViewController *)parent __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment