相关疑难解决方法(0)

何时使用addChildViewController vs pushViewController

我刚看了2011年WWDC关于"实现UIViewController遏制"的演示文稿(这里是视频的链接)

他们提到了将viewControllers添加到屏幕的两种方法,我希望对最佳实践做一些澄清......

addChildViewController/removeFromParentViewController
与@property(非原子,只读)NSArray*childViewControllers一起使用[self transitionFromViewController:currentView toViewController:nextView duration: options: animations: completion:];

pushViewController:animated:/ popViewControllerAnimated
他们很快就在演示文稿中快速浏览了这个

在我的应用程序中,我使用所有自定义viewControllers,直到今天我一直使用以下方法管理它们:

[nextController performSelector:@selector(setDelegate:) withObject:self];
[currentPageController.view removeFromSuperview];
[self.view addSubview:nextController.view];
Run Code Online (Sandbox Code Playgroud)

但我现在明白了,这是不好的做法,我想知道什么是使用"addChildViewController",什么是使用"pushViewController"正确的方法正确的方法是什么?

我非常感谢你对此事的看法!

iphone addchild uiviewcontroller pushviewcontroller

34
推荐指数
1
解决办法
5万
查看次数