我有一个带有不同 ViewController 的 NavigationController。有时我想将 ViewController 推送到 NavigationController,它已经包含在内。 在这种情况下,我想从 TopController 移动到现有的,并弹出顶部和现有的之间的所有其他 ViewController。
有没有办法给 ViewController 一个特殊的 id(例如 NSString),以便稍后在“NavigationController.viewControllers”中找到他? 或者我应该使用单独的字典来管理我的 ViewControllers?
或者有没有更好的方法,我不考虑。
最好的问候
最佳答案
在你的 appDelegate 上,你可以存储你所有的 ViewController 以及你想要弹出调用的时间:
[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;
}
}
希望对你有所帮助。
关于ios - 使用特殊键在 NavigationController 中找到 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26407380/