Kühlhausvogel
Kühlhausvogel

Reputation: 76

When to used 'show' and 'unwind' segues?

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?

Upvotes: 0

Views: 136

Answers (2)

Divyansh Tangri
Divyansh Tangri

Reputation: 1

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.

Upvotes: 0

rishi
rishi

Reputation: 11839

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.

Upvotes: 1

Related Questions