0

I am building an app with 6 ViewController (lets call them A, B, C, D, E and F). A is the "Menu" ViewController.

From A you can reach B or F.
From B you can go back to A or go on to C.
From C you can go back to B or go on to D.
From D you can go back to C or go on to E.
From E you can NOT go back to D, but you can go back to A or to B.
From F you can only go back to A.

here u can see the "storyboard"

The question

Which segues should be 'show' segues and which segues should be 'unwind' segues? Or is there maybe something else I should use?

2 Answers2

1

Show - forward

unwind - backward

So for e.g. -

when moving from A -> B use show

now when coming back i.e. B -> A use unwind.

rishi
  • 11,779
  • 4
  • 40
  • 59
  • yeah but you can just unwind to ONE specific viewcontroller right? Or is there a possibility to unwind FROM E to A and B? – Kühlhausvogel Apr 06 '18 at 09:08
  • You can unwind to ANY view controller so long as it is back in the hiearchy – Happiehappie Apr 06 '18 at 09:10
  • unwind process get the previous instance automatically, so you will go back automatically. Apple Tech notes describes the same - https://developer.apple.com/library/content/technotes/tn2298/_index.html – rishi Apr 06 '18 at 09:12
  • Ok I think I was too unspecific: Is it possible to have 2 unwind segues from one ViewController? For example to have an unwind segue going back from E to A and another one going back from E to B? – Kühlhausvogel Apr 06 '18 at 09:20
  • you can refer this SO post - https://stackoverflow.com/questions/12561735/what-are-unwind-segues-for-and-how-do-you-use-them – rishi Apr 06 '18 at 10:01
0

If you use "show" segue then you will use unwind to go back to any ViewController that has come before it in the view hierarchy but if you use "present modally" then you have to use dismiss to get back. Though with unwind you can go from the latest ViewController to the first most ViewController but with dismiss only the latest ViewController gets dismissed. And you can have as many unwinds as you want as long as you create an @IBAction for each and provide identifier.