当我从导航栏按回按钮时,我正在尝试跳过一个ViewController
。
当我进入下一个VC时,它需要这样做:
A -> B -> C
但是当我想从C回来时,我想要呈现A ViewController
:
C -> A
我设法用下一个代码做到了:
NSMutableArray *newControllers = [[NSMutableArray alloc]initWithArray:controllers];
[newControllers removeObjectAtIndex:newControllers.count-2];
self.navigationController.viewControllers = newControllers;
问题是出现的导航栏。当我从A ViewController
获取View时,会出现B ViewController的导航栏。
有没有办法可以删除导航栏项目,比如我从层次结构中删除了视图控制器?
答案 0 :(得分:6)
UIViewController *vcPop = nil;
for (UIViewController *viewContrl in self.navigationController.viewControllers) {
if ([viewContrl class] == [YOUR POP VIEW CONTROLLER class]) {
vcPop = (YOUR POP VIEW CONTROLLER *)viewContrl;
break;
}
}
if(vcPop)
[self.navigationController popToViewController:vcPop animated:YES];