当遇到两个同级界面,又是用navigationController push出来的界面时,则可以考虑替换self.navigationController.childViewControllers的栈顶的controller
例如注册与登录这种同级界面的切换
代码如下:
RegisterViewController *controller = [[RegisterViewController alloc] init];
NSArray *array = self.navigationController.childViewControllers;
NSMutableArray *newArray = [NSMutableArray arrayWithArray:array];
[newArray removeLastObject];
[newArray addObject:controller];
[self.navigationController setViewControllers:newArray animated:NO];
这样pop回前一个界面时就不会在这两个同级界面纠结了