我通过单击按钮将用户转到某个页面。此页面是一个 UITableViewController。
现在,如果用户点击一个单元格,我想将他推回到上一页。
我想到了类似self.performSegue("back")....
的方法,但这似乎不是个好主意。
正确的做法是什么?
最佳答案
swift 3:
如果你想回到之前的view controller
_ = navigationController?.popViewController(animated: true)
如果你想回到 Root View Controller
_ = navigationController?.popToRootViewController(animated: true)
如果您没有使用导航 Controller ,请使用以下代码。
self.dismiss(animated: true, completion: nil)
您可以根据需要设置动画值。
关于ios - 以编程方式返回到 Swift 中的上一个 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28760541/