Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an 'Unwind Segue' work between two storyboards connected by a storyboard reference?

In iOS 9, storyboards can be connected by a 'storyboard reference' that links to a second storyboard by adding a storyboard reference and setting the 'referenced ID' to the name of another storyboard file.

Is it possible to set up an unwind segue in the second file that unwinds to a scene in the first file? If so, what steps are involved, either in Interface Builder or in code?

like image 344
Iain Delaney Avatar asked Oct 27 '15 13:10

Iain Delaney


People also ask

How do you connect unwind segue?

As far as how to use unwind segues in StoryBoard... In storyboard, go to the view that you want to unwind from and simply drag a segue from your button or whatever up to the little orange "EXIT" icon at the top right of your source view. That's it, your segue will unwind when your button is tapped.

How do you create a relationship segue in a storyboard?

To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.

Can we use multiple storyboards in one application?

An app's storyboard can be easily divided into multiple storyboards, with each one representing an individual story. Best example will be Pre-Login flow. Splash Screen, Login, Signup, Forgot Password, T&C etc can be easily seen as a separate flow independent of the functionalities in the app.

Can you have multiple storyboards Xcode?

Apple introduced them in iOS 9 and macOS 10.11. They do exactly what I needed. They allow you to break a storyboard up into multiple, smaller storyboards. A storyboard reference ties multiple storyboards together, creating one, large, composite storyboard.


2 Answers

I didn't have to make a storyboard reference back from the 2nd storyboard to the first as Ryan laid out. For me, in my second storyboard I could Control-drag from a viewcontroller to its own exit, and the unwind segue that I had specified in a viewcontroller class consumed in the first storyboard appeared. So I just selected that to create a new exit segue with an identifier, and called performSegueWithIdentifier: on it in code. Worked fine.

like image 103
xaphod Avatar answered Sep 16 '22 15:09

xaphod


Starting from your storyboard reference, create a new storyboard reference that will be a reference back to your "Main" storyboard. Make sure you set your Storyboard Identifier on your main as well.

You will now have a "Main Scene" reference with all you Exits now available. You can now create unwind segues as you normally would. Ctrl-drag from your controller to the Exit marker on the Main Scene and you will be able to select the desired exit.

enter image description here

like image 29
Ryan Romanchuk Avatar answered Sep 18 '22 15:09

Ryan Romanchuk