新增刪除子檢視控制器
要新增子檢視控制器:
- (void)displayContentController:(UIViewController *)vc {
[self addChildViewController:vc];
vc.view.frame = self.view.frame;
[self.view addSubview:vc.view];
[vc didMoveToParentViewController:self];
}
要刪除子檢視控制器:
- (void)hideContentController:(UIViewController *)vc {
[vc willMoveToParentViewController:nil];
[vc.view removeFromSuperview];
[vc removeFromParentViewController];
}