小编Sta*_*ack的帖子

swift3中的segue时间如何关闭当前视图控制器

这是我的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)

但这没用。有人可以帮我吗?

view identifier dismiss segue swift3

1
推荐指数
1
解决办法
2013
查看次数

标签 统计

dismiss ×1

identifier ×1

segue ×1

swift3 ×1

view ×1