一、介绍
老规矩先看SDK
Container view controllers are a critical part of iOS app design. They allow you todecompose your app into smaller and simpler parts, each controlled by a viewcontroller dedicated to that task. Containers allow these view controllers towork together to present a seamless interface.
就是说,容器型的viewController能够把app分为很多小而简单的部分来管理,允许他们一起无缝的展示用户界面。
其实应该已经接触过了一些container,viewcontrollers 经常很container一起工作。例如NavigationController、TabBar就是几个典型的container,它可以管理很多view controller。这次就来小小的研究一下customer container。
二、API
addChildViewController:
removeFromParentViewController
transitionFromViewController:toViewController:duration:options:animations:completion:
willMoveToParentViewController:
didMoveToParentViewController:
基本上就是这几个方法。
三、用法
- 添加子节点
//定义child
First *first = [[Firstalloc]initWithNibName:@"First"bundle:nil];
//添加child
[selfaddChildViewController:first];
- 获得子节点
[self.childViewControllersobjectAtIndex:0];
添加进入的子节点是有顺序的,从0开始。
- 获取子节点的个数
self.childViewControllers.count