控制器中添加控制器的常见方法

控制器中添加控制器的常见方法: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];

 

未完待续

相关文章
相关标签/搜索