使用特殊键在NavigationController中查找ViewController [英] Find ViewController in NavigationController with special key
问题描述
我有一个带有不同ViewController的NavigationController.有时我想将ViewController推送到NavigationController(已包含在内)中. 在这种情况下,我想从TopController移至现有控制器,并在top与现有控制器之间弹出所有其他ViewController.
I have a NavigationController with different ViewControllers. Sometimes I want to push a ViewController to NavigationController, which is already included. In this case I want to move to the existing from TopController, and pop all other ViewControllers between top and the existing one.
是否可以给ViewController一个特殊的ID(例如NSString),以便稍后在"NavigationController.viewControllers"中找到他? 还是应该使用单独的Dictionary管理我的ViewController?
Is there a way to give a ViewController a special id (for example a NSString), to find him later in "NavigationController.viewControllers"? Or should I use a seperate Dictionary to manage my ViewControllers?
或者我没有更好的方法.
Or is there a better way, I dont consider.
最诚挚的问候
推荐答案
在appDelegate上,您可以存储所有ViewController以及要弹出呼叫的时间:
On your appDelegate, you can store all your ViewController and when you want to pop call :
[self.navigationController popToViewController:yourViewController animated:YES];
或者您可以尝试搜索
NSArray *viewControllers = self.navigationController.viewControllers
for (UIVIewController *anVC in viewControllers) {
if (anVC isKindOfClass:[yourController class] {
[self.navigationController popToViewController:anVC animated:YES];
break;
}
}
希望它会对您有所帮助.
Hope it will help you.
这篇关于使用特殊键在NavigationController中查找ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!