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

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

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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top