控制器中添加控制器的常见方法:
1 添加子控制器:addChildViewController:
2 modal出控制器: presentViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#> completion:<#^(void)completion#>
3 设置为rootViewController
4 UINavgationController push出来控制器:pushViewController:<#(nonnull UIViewController *)#> animated:<#(BOOL)#>
5 UINavgationController 跳转到最新的一个控制器:(不管是push出来的还是pop出来的)
- (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.
用法实例:
NSMutableArray *vcs = self.navigationController.viewControllers.mutableCopy;
[vcs removeLastObject];
SS_SaleStatisticsVC *vc = [[UIStoryboard storyboardWithName:@"SS_SaleStatisticsVC" bundle:nil] instantiateInitialViewController];
[vcs addObject:vc];
[self.navigationController setViewControllers:vcs animated:YES];
未完待续
来源:oschina
链接:https://my.oschina.net/u/2682077/blog/740025