当前位置: 代码迷 >> 综合 >> UINavigationController 返回总结
  详细解决方案

UINavigationController 返回总结

热度:0   发布时间:2023-12-11 14:25:21.0

1.当前视图控制器消失,并向左显示前一个视图

[self.navigationController popViewControllerAnimated:YES];  

2.返回到根视图控制器

[self.navigationController popToRootViewControllerAnimated:YES]; 

3.返回到指定视图控制器(回到指定视图控制器,也就是不只弹出一个)

[self.navigationController popToViewController:viewController animated:YES];  

例如:

[self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex: ([self.navigationController.viewControllers count] -3)] animated:YES];


    for (UIViewController *controller in self.navigationController.viewControllers) {

        if ([controller isKindOfClass:[你要跳转到的Controller class]]) {

            [self.navigationController popToViewController:controller animated:YES];

        }

    }