[英]Go back for 2 segues while clicking at back button
I have 3 ViewControllers
which segue operations is prepared more or less like this: 我有3个
ViewControllers
,它们或多或少准备了如下的segue操作:
A --editview-> B ---showEdited->C
Where A
is for list of objects B
is for edit certain object and C
is for showing edited object. 其中
A
用于对象列表, B
用于编辑某些对象, C
用于显示已编辑的对象。 At this moment when user is getting into C
and trying to go back he is landing in edit state B
instead of a list. 此时,当用户进入
C
并尝试返回时,他将进入编辑状态B
而不是列表。 Is it possible to close segue while performing to the new one? 在执行新游戏时是否可以关闭segue? so that user will be back from
C
to A
? 这样用户将从
C
回到A
?
I don't know if I understand correctly what you want to do but I hope this will work. 我不知道我是否正确理解您要做什么,但我希望这会奏效。
if let firstVC = self.navigationController?.viewControllers[0] {
self.navigationController?.popToViewController(firstVC, animated: true)
}
Have you tried looking into unwind segues. 您是否尝试过研究放松的话题。 Unwind segues help when you have a sequence of VCs, say 1 -> 2 -> 3, and an unwind segue takes you from 3 directly back to 1.
当您拥有一系列VC时(例如1-> 2-> 3),放开序列会有所帮助,放开序列会使您从3直接回到1。
Try these links: 试试这些链接:
https://spin.atomicobject.com/2014/10/25/ios-unwind-segues/ https://spin.atomicobject.com/2014/10/25/ios-unwind-segues/
What are Unwind segues for and how do you use them? 什么是Unwind segues,您如何使用它们?
Hope this helped. 希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.