如何返回 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我并不是有意无礼,但这确实有详细记录。在 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:
To pop to a specific view controller, you use:
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.
看看
popViewControllerAnimated:
。从文档中:
此方法从堆栈中删除顶部视图控制器,并使堆栈的新顶部成为活动视图控制器。
用法如下:
Take a look at
popViewControllerAnimated:
.From the documentation:
This method removes the top view controller from the stack and makes the new top of the stack the active view controller.
Usage is something like:
Swift 3 版本
要弹出到特定视图控制器,您可以使用:
您必须首先遍历视图控制器列表,然后根据您要查找的内容检查标题,然后将其传递给此方法。
Swift 3 version
To pop to a specific view controller, you use:
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.