Should EXPLICITLY call willMoveToParentViewController:(UIViewController *)parent & didMoveToParentViewController:(UIViewController *)parent?

StackOverflow https://stackoverflow.com/questions/13617825

Question

In the WWDC 2012 Session titled The Evolution of View Controllers on iOS - (void)willMoveToParentViewController:(UIViewController *)parent and - (void)didMoveToParentViewController:(UIViewController *)parent have been mentioned to be used in custom container implementation for view transitions.

If I'm not mistaken, it seems to require to call these methods EXPLICITLY, either before - (void)removeFromSuperview or after - (void)addSubview:(UIView *)view

However, when I logged them inside sub class implementations, it shows that they have been called IMPLICITLY. They have been called at the right places automatically.

So, I'm a little confused if these methods ARE REALLY NEEDED to be called explicitly, like instructed in the WWDC Session, or it's ok not to follow it and clear out unnecessary lines of codes.

Was it helpful?

Solution

Explained in my book:

http://www.apeth.com/iOSBook/ch19.html#_container_view_controllers

Basically one of the two is indeed implicitly called but the other you must call explicitly. It's maddening; I have to look up the rules every time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top