从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];