I just watched a 2011 WWDC
presentation on "Implementing UIViewController Containment" (here's a link to the video)
They mentioned both of these ways of adding viewControllers to the screen, and I would appreciate some clarification on best practices...
addChildViewController / removeFromParentViewController
used with an @property (nonatomic, readonly) NSArray *childViewControllers and [self transitionFromViewController:currentView toViewController:nextView duration: options: animations: completion:];
pushViewController: animated: / popViewControllerAnimated
they really quickly skimmed past this in the presentation
In my apps I use all custom viewControllers, and until today I have always managed them with:
[nextController performSelector:@selector(setDelegate:) withObject:self];
[currentPageController.view removeFromSuperview];
[self.view addSubview:nextController.view];
But I understand now that this is bad practice, and I'm wondering what is the correct way to use "addChildViewController" and what is the correct way to use "pushViewController"?
I really appreciate your thoughts on the matter!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…