本文介绍了究竟是什么意志移动到一个明确的控件:和didMoveToParentViewController:做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道从iOS5和新的UIViewController包含方法开始,您应该将这些方法与 addChildViewController: removeFromParentViewController:和转换方法一起调用。我也知道在三种情况下调用它们的正确顺序。我不知道这些方法究竟是做什么的?

I know that starting with iOS5 and the new UIViewController containment methods, you are supposed to call these methods together with addChildViewController:, removeFromParentViewController: and the transition method. I also know the proper order of calling them in the three scenarios. What I don't know is what exactly these methods do?

如果这些只是UIViewController子类的覆盖点,我想我们不需要调用。如果在删除视图控制器或 didMoveToParentViewController:self 之前没有调用 willMoveToParentViewController:nil ,会出现什么问题?

If these were merely override points for subclasses of UIViewController I guess we wouldn't be required to call super when overriding. What can/will go wrong if I don't call willMoveToParentViewController: nil before removing a view controller or didMoveToParentViewController: self?

推荐答案

除了已经说过的内容之外,他们确实调用了一些委托方法:

In addition to what has been said, they do call some delegate methods:

addChildViewController 调用 [child willMoveToParentViewController:self]

removeFromParentViewController:调用 [child didMoveToParentViewController:nil]

此外,他们还修改了 childViewControllers 属性,该属性包含一组子视图控制器。

Also, they modify the childViewControllers property, which holds an array of child view controllers.

这篇关于究竟是什么意志移动到一个明确的控件:和didMoveToParentViewController:做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 11:02