Sta*_*ack 1 view identifier dismiss segue swift3
这是我的segue方法。假设此方法位于ParentViewController中。
override fu n c prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "subViewController" {
// Before appears in the screen.
let subViewController = segue.destination as! SubViewController
subViewController.currentMarks = sender as? Int16
}
Run Code Online (Sandbox Code Playgroud)
它工作完美。现在进入SubViewController。在这里,我正在做某事,并且在这里有一个按钮。每当我单击此按钮时,它都应该关闭SubViewController并需要打开ParentViewController(因为它已经处于打开状态,所以无法打开)。
确切地说,每当我单击SubViewController中的按钮时,subViewController只需关闭然后我就会自动看到ParentViewController(因为已经打开了一个,但我没有关闭对吗?)。
如何实现这种机制?在SubViewController按钮操作中,我这样写:
self.navigationController?.dismiss(animated: true, completion: {
})
Run Code Online (Sandbox Code Playgroud)
但这没用。有人可以帮我吗?
如果在stoyboard上创建segue时选择了show。在您的按钮中单击以下命令:
self.navigationController?.popViewController(animated: true)
Run Code Online (Sandbox Code Playgroud)
如果您选择“ 当前”模态,则调用此:
self.dismiss(animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)