以编程方式返回到Swift中的前一个ViewController [英] Programmatically go back to previous ViewController in Swift
本文介绍了以编程方式返回到Swift中的前一个ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过点击按钮将用户发送到页面。此页面是 UITableViewController 。
I send the user over to a page on a button click. This page is a UITableViewController.
现在,如果用户点击一个单元格,我想将他推回到上一页。
Now if the user taps on a cell, I would like to push him back to the previous page.
我想过像 self.performSegue(返回)....
之类的东西,但这似乎是一个坏主意。
I thought about something like self.performSegue("back")....
but this seems to be a bad idea.
这样做的正确方法是什么?
What is the correct way to do it?
推荐答案
Swift 3:
如果你想回到上一个视图控制器
If you want to go back to the previous view controller
_ = navigationController?.popViewController(animated: true)
如果你想回到根视图控制器
If you want to go back to the root view controller
_ = navigationController?.popToRootViewController(animated: true)
这篇关于以编程方式返回到Swift中的前一个ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文