Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 201
petershine Avatar asked Nov 29 '12 02:11

petershine


1 Answers

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.

like image 54
matt Avatar answered Nov 15 '22 17:11

matt