ChildViewContrller
1.添加childVC
self.photoVC = MainStoryboardViewController(kFilePicker_Photo);
self.videoVC = MainStoryboardViewController(kFilePicker_Video);
self.audioVC = MainStoryboardViewController(kFilePicker_Audio);
self.otherVC = MainStoryboardViewController(kFilePicker_Other);
// [self addChildViewController:self.docVC];
[self addChildViewController:self.photoVC];
[self addChildViewController:self.videoVC];
[self addChildViewController:self.audioVC];
[self addChildViewController:self.otherVC];
2.切换视图
_currViewController 当前显示的vc
_currViewController=_homeViewController;
[self.ChildView addSubview:_currViewController.view];
UIViewController *removeVC = self.childVCs[self.selectIndex];//这个是当前显示的vc
UIViewController *showVC = self.childVCs[index];//将要显示的VC
//记得修改显示的frame
<strong>showVC.view.frame = self.containnerView.bounds;</strong>
//切换
__weak typeof(self) weakSelf = self;
[self transitionFromViewController:removeVC
toViewController:showVC
duration:0.2f
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
[removeVC.view removeFromSuperview];
}
completion:^(BOOL finished) {
[weakSelf.containnerView
addSubview:showVC.view];
}];