前言
在工作中遇到这样一个问题 一个容器有两个childController 在子Controller 中的viewDidLoad中获取self.navigationController 的时候发现为nil 不理解 addChildViewController: addSubview: 以及设置view的frame方法的调用顺序影响了
addChildViewController: 在iOS5.0之后开始使用 一个controller 对应一个view 降低耦合度
当然一系列的调用顺序大家也要注意..别的博客中也给了大体的顺序.
在developer 中可以看到
Discussion
This method creates a parent-child relationship between the current view controller and the object in the childController
parameter. This relationship is necessary when embedding the child view controller’s view into the current view controller’s content. If the new child view controller is already the child of a container view controller, it is removed from that container before being added.
This method is only intended to be called by an implementation of a custom container view con