简体   繁体   English

单击“后退”按钮时返回2段

[英]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.

相关问题 Swift-如何编写一个按钮以进入mainScene,而没有回退? - Swift - How to program a button to go to the mainScene, without segues going back? 单击“返回”按钮时添加功能-ios - add functionality when clicking go back button -ios 后退按钮不返回 - back button doesn't go back 如何在 Titanium 中播放时将 go 后退 5 秒,单击按钮时应该会发生这种情况 - How to go back 5 secs back while playing in Titanium, on button click this should happen 在UIWebview上单击某些链接时,它会自动连接(转到)iTunes。 但单击iTunes链接后无法返回到应用程序 - While clicking on some links on UIWebview it's automatically connect(go) to the itunes. but cannot get back to the app after clicking a iTunes link 单击UINavigationBar中的“上一步”按钮时,UIScrollView滚动 - UIScrollView scrolls when clicking “Back” button in UINavigationBar 单击后退按钮为iPhone屏幕动画 - animate iphone screen on clicking back button iOS 单击时后退按钮文本消失 - iOS back button text disappears when clicking 导航控制器中的“后退”按钮上的应用程序崩溃 - application crashing on clicking back button in navigation controller “程序后退”按钮可返回到名为self.presentViewController的位置 - Program Back button to go back where it was called self.presentViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM