我在 UINavigationController
上遇到问题...
我有这个层次结构
UINavigationController
|- root controller
|- ViewController A
我在ViewController A
中有一个按钮做某事并插入ViewController B
,但我想删除 ViewController A
添加ViewController B
之前
所以处理后的层次结构是这样的
UINavigationController
|- root controller
|- ViewController B
它应该是从 ViewController A
滑动的至 ViewController B
,但如果按返回键,则会返回 root Controller
提前谢谢你。
最佳答案
您应该使用 UINavigationController 的 setViewControllers 方法,并简单地将 root 和 viewController B 添加为数组
//get the existing navigationController view stack
NSMutableArray* newViewControllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
//drop the last viewController and replace it with the new one!
ViewControllerB *childController = [[ViewControllerB alloc] initWithNibName:@"ViewControllerB" bundle:nil];
[newViewControllers replaceObjectAtIndex:newViewControllers.count-1 withObject:self];
//set the new view Controllers in the navigationController Stack
[self.navigationController setViewControllers:newViewControllers animated:YES];
关于iphone - 如何在NavigationController上弹出UIViewController并同时推送UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12933007/