我刚刚观看了 2011 年WWDC
关于“实施 UIViewController 遏制”的演示(这里是视频的链接)
他们提到了将视图控制器添加到屏幕的这两种方法,我希望能对最佳实践进行一些澄清......
addChildViewController / removeFromParentViewController
与 @property(非原子,只读)NSArray *childViewControllers 和[self transitionFromViewController:currentView toViewController:nextView duration: options: animations: completion:];
pushViewController: animated:/popViewControllerAnimated
他们真的很快就在演示文稿中略过了这个
在我的应用程序中,我使用所有自定义视图控制器,直到今天我一直使用以下方法管理它们:
[nextController performSelector:@selector(setDelegate:) withObject:self];
[currentPageController.view removeFromSuperview];
[self.view addSubview:nextController.view];
但我现在明白这是不好的做法,我想知道使用“addChildViewController”的正确方法是什么,使用“pushViewController”的正确方法是什么?
我非常感谢您对此事的看法!