【发布时间】:2020-11-19 20:17:45
【问题描述】:
我正在尝试解除模态 ViewController,然后自动移动到下一个 ViewController。我用这个 unwind segue 和 performSegue inside unwind。
@IBAction func unwindWithChatTo(unwindSegue: UIStoryboardSegue) {
performSegue(withIdentifier: "chatStartTwo", sender: nil)
}
问题:在 performSegue 执行后出现下一个 ViewController 后,执行了不需要的 segue 回到第一个视图。
流程: 模态视图 -> 1VC -> 2VC -> 1VC(不需要的)
这种不必要的转回可能是什么原因以及如何解决这个问题?
我没有找到任何关于这种情况的建议。非常感谢您的建议。
【问题讨论】:
-
unwindWithChatTo方法在哪个类中?展开方法需要在呈现控制器中,而不是模态控制器中。您也只能放松到该控制器,而不是另一个控制器(afaicr)。我会考虑使用带有完成块的dismiss方法来启动下一个VC的luanch。 -
谢谢!我最终决定不在这里使用 unwind 并且它起作用了。
标签: swift segue unwind-segue