如何在 UINavigationController 中返回一个视图? [英] How to go back one view in UINavigationController?
问题描述
有没有一种方法可以在 UINavigationController
上返回堆栈中的一个视图?还是到具有特定标题的视图?
Is there a method to go back one view in the stack on a UINavigationController
? Or to a view with a specific title?
推荐答案
我并不是要粗鲁,但这确实有据可查.在 UINavigationController 上进行 google 搜索甚至是 Apple 文档搜索都会找到您需要的内容.以编程方式弹出您使用的当前视图控制器:
I don't mean to be rude, but this is really well documented. A google search or even an Apple documentation search on UINavigationController will turn up exactly what you need. To programmatically pop the current view controller you use:
[[self navigationController] popViewControllerAnimated:YES];
要弹出到特定的视图控制器,请使用:
To pop to a specific view controller, you use:
[[self navigationController] popToViewController:controller animated:YES];
您必须首先遍历视图控制器列表,并根据您要查找的内容检查标题并将其传递给此方法.
You will have to iterate through the list of view controllers first and check the title against what you're looking for and pass that to this method.
这篇关于如何在 UINavigationController 中返回一个视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!