UINavigationController: How do I delete a view of a stack
假设这是我的堆栈布局
1 2 3 4 | View3 --> Top of the stack View2 View1 HomeView --> Bottom of the stack |
所以我现在在
您可以使用poptorootviewcontrolleranimated:来访问根视图控制器。这将弹出堆栈中除根视图控制器之外的所有视图控制器。在您的情况下,这将是主视图。
1 | [self popToRootViewControllerAnimated:YES]; |
< BR>要获取堆栈中的特定视图,可以使用poptoViewController:animated:假设要弹出第三个视图控制器(自下而上)。在您的情况下,这将是视图2:
1 2 3 | NSArray* viewControllersInStack = self.navigationController.viewControllers; UIViewController* targetViewController = [viewControllersInStack objectAtIndex:2]; [self.navigationController popToViewController:targetViewController animated:YES]; |
使用PopToViewController
1 | [self.navigationController popToViewController:homeView animated:YES]; |
使用…
[self.navigationcontroller poptorootview controller动画:是];