我试图通过在 IBAction
中调用 dismissViewController
快速关闭 ViewController
@IBAction func cancel(sender: AnyObject) {
self.dismissViewControllerAnimated(false, completion: nil)
println("cancel")
}
@IBAction func done(sender: AnyObject) {
self.dismissViewControllerAnimated(false, completion: nil)
println("done")
}
我可以在控制台输出中看到 println 消息,但 ViewController 从未被关闭。可能是什么问题呢?
最佳答案
从你的图片来看,你似乎使用推送呈现了 ViewController
dismissViewControllerAnimated
用于关闭使用模态呈现的 ViewController
swift 2
navigationController.popViewControllerAnimated(true)
swift 4
navigationController?.popViewController(animated: true)
dismiss(animated: true, completion: nil)
关于ios - 如何在 Swift 中关闭 ViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24668818/