从View1进入View2,但是在View2的返回不想退回View1。
UINavigationController先pop再push,push操作将无效。
解决方案是:
1. 从self.navigationController.viewControllers中拿出需要保留的View Controller放到一个数组中
2. 向数组中添加需要push的View Controller
3. 调用[self.navigationController setViewControllers:array animated:YES]
具体代码:
InvestmentViewController *investmentList = [[InvestmentViewController alloc] init];
investmentList.hidesBottomBarWhenPushed = YES;
NSMutableArray *arrView = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
int index = (int)[arrView indexOfObject:self];
[arrView removeObjectAtIndex:index];
[arrView addObject:investmentList];
[self.navigationController setViewControllers:arrView animated:YES];
本文介绍了一种在iOS应用中使用UINavigationController时,如何实现从一个视图控制器返回时不退回到特定页面的方法。通过保存需要保留的视图控制器到数组中,并移除不需要保留的视图控制器,最后设置navigationController的viewControllers属性来达到目的。
5769

被折叠的 条评论
为什么被折叠?



