我创建了一个模块,其中有5个类,我需要执行类似的任务
vc1->vc2->vc3
现在从vc3开始,我曾经从基类的引用中推送vc4。基类是添加vc1控制器作为子视图的类。
现在我需要从vc4跳到vc3。
NSInteger index = 0;
for (UIViewController *view in self.navigationController.viewControllers) {
if([view.nibName isEqualToString:@"YourViewController"])//put any `XIB name` where u want to navigate
break;
index = index + 1;
}
//[[self navigationController] pushViewController:[[self.navigationController viewControllers] objectAtIndex:index] animated:YES];
[[self navigationController] popToViewController:[[self.navigationController viewControllers] objectAtIndex:index] animated:YES];
NSArray *array = [self.navigationController viewControllers];
[self.navigationController popToViewController:[array objectAtIndex:2] animated:YES];
获取要弹出到的视图控制器的索引。
请参阅以下链接:-
我可以弹出到特定的ViewController吗?
弹出特定的视图控制器