Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS routing viewDidAppear to child view controllers?

I'm adding a child view controller to a parent view controller, and everything works as expected, except that child view controller isn't having its usual callbacks triggered. eg, things like viewWillAppear(animated) is never called. I looked into it and thought it may be because I wasn't calling willMoveToParentViewController and didMoveToParentViewController on the child view controller before and after adding it to the parent, respectively. Unfortunately, fixing that has made no difference. Does anyone know how I can wire this up so that when I do addChildViewController and removeChildViewController the regular callbacks are triggered? After adding the childViewController, I also add its view as a subview to the parent view controller's view. At neither point (addChildViewController & addSubview) does the child view controller's viewWillAppear(animated), etc methods get called...

Nick

like image 724
pachun Avatar asked Dec 24 '13 02:12

pachun


1 Answers

Try this one:

childController.willMoveToParentViewController(self)
childController.beginAppearanceTransition(true, animated: true)

after added to your view controller

like image 124
patuan81 Avatar answered Sep 21 '22 19:09

patuan81