控制器中添加控制器的常見方法:spa
1 添加子控制器:addChildViewController:rem
2 modal出控制器: presentViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#> completion:<#^(void)completion#>it
3 設置爲rootViewControllerio
4 UINavgationController push出來控制器:pushViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#>table
5 UINavgationController 跳轉到最新的一個控制器:(不論是push出來的仍是pop出來的)ast
- (void)setViewControllers:(NSArray<UIViewController *> *)viewControllers animated:(BOOL)animated NS_AVAILABLE_IOS(3_0); // If animated is YES, then simulate a push or pop depending on whether the new top view controller was previously in the stack.方法
用法實例:im
NSMutableArray *vcs = self.navigationController.viewControllers.mutableCopy;top
[vcs removeLastObject];tab
SS_SaleStatisticsVC *vc = [[UIStoryboard storyboardWithName:@"SS_SaleStatisticsVC" bundle:nil] instantiateInitialViewController];
[vcs addObject:vc];
[self.navigationController setViewControllers:vcs animated:YES];
未完待續