Playing.
Sometimes when you work on specifically larger applications it makes sense that you break your storyboards
into several different fights.
Let's letting your application has 10 different views and every view has some you know supporting UI
views and whatnot.
And for that it really is no better if you actually have more than one storyboard.
And if you have that you have to learn how to segway between not just the viewer contours of the same
storyboard but rather the view controllers of multiple storyboards.
I'm going to show you two different ways.
One of them is purely based on their interface and the other one is with some programmatic approaches
as well.
So let's have a look at both of them.
And when I go to court and when I start a new application called segway to a storyboard UI in the user
interface not with programming.
So here I'm going to go to my storyboard and then when I assume that I have one button and this button
is supposed to take us to another storyboard and victim there another view controller.
So my button says go to next and it has a different background such as this one.
Now I need another a storyboard file so to do that I'm going to say fine you fine and yet I'm going
to choose a storyboard.
I'm gonna say this is next.
And I'm actually going to call it Next a storyboard so next dot a storyboard.
So now this is a story that doesn't have anything in it but what they do need is a view controller.
So we have a view controller in my newer storyboard and maybe this view controller has the same green
color.
And this is now supposed to be my green view control of when I go to of course just just like any other
Storyboard You can have your view controller classes are added in here.
You can for instance have a cockroach touch classless call it green view controller and in your next
you can just connected there.
Just like if you had it in any other a storyboard essentially.
Once I have my view controller in the other a storyboard taking care of I'm going to head back to my
main storyboard and in a year I need a V to go from here to the previous a story.
So to do that I'm going to go up here and I'm going to add a different object that is called a storyboard
reference and that's essentially a way to providing a place holder for a view controller in an external
storyboard.
So I'm going to add that and that's a reference to another storyboard.
So for that I'm going to go in here in the attributes and say this is truly what I want to get the reference
to is actually next and then it's telling me so Veatch referenced I.D. do you want to use which of you
controller is the idea for the view controller do you want to go to and that's something I haven't set
yet.
So and then go to my next storyboard the game select my view controller and say this view controller
actually has an a storyboard idea.
So let me come in here zoom into this area and say this view contour has an a storyboard idea that is
called Green the V.C. idea.
So I'm going to copy that name go to my main storyboard again select my reference and say from next
I want to get to this one go up green V.S. idea and then everything is as usual I could just select
the green by then all the control and draw and you say Great say present more daily.
The reason I'm doing Woodley and not show is because I don't have a navigation controller the Mercy
present modelling and maybe my model I'm going to change the transition type I'm going to say to the
Flip horizontal.
And now everything is set for an application to essentially make a transition between one a storyboard
to another storyboard using a Segway to the reference a storyboard.
If I press on the green now we essentially get navigated to the storyboard of the other fight.
And from this point on we're essentially here we we're within the next storyboard and we can do whatever
we wanted to doing here.
Keep in mind that when you did the reference in the main a storyboard here if I actually cut this for
a second it says what is the initial view controller of the either a storyboard.
So that's the initial one that we land in there and then you can do whatever you want to do from that
point on.
So that was one way of doing it.
That is essentially doing everything in the interface builder.
Now I'm going to show you another way of doing the same thing with this thing.
We're going to do it entirely programmatically so I'm going to start a new application that's called
this one the Segway to another storyboard programmatic it's a long name for an application by the state.
So I have my main a storyboard.
It has a white bank on it and hopefully a button soon.
I have a newer storyboard Fire Command and a storyboard.
This is called the next.
Just like the last time between my next I have a view controller this viewpoint or I'm going to make
it look green perhaps so we can actually see it more distinctly that screen and the very same process
that we did last time.
In terms of setting titles and ideas we have to do it in here as well.
So once again I'm going to stick my dream view controller coin here and say a storyboard a different
is green view controller I.D. I'm going to copy that name and then I'm gonna go to I mean a storyboard
and have a button.
I'm gonna say that by then is placed in here.
I actually let it have some constraint so it doesn't look as ugly as usual of 400 there.
Not have it.
No but 20.
Okay.
And then my then is going to have a bank gone.
That is also green and says Go to Green.
And of course I have to add a function for this by then.
So I'm going to load up my assistant window and in my system even though I'm going to say I don't need
the view that load but they do need is an action and that action is saying go to Green Action Now.
Everything that we have to actually do programmatically happens within here.
And this is actually kind of important because from time to time you end up using this system as opposed
to doing everything in the interface builder.
So the first thing they have to do is I have to get access to my next storyboard.
So I'm going to say let's next storyboard that's going to become UI a storyboard and I'm going to make
it using a name within a bundle for the bundle they have a name.
So it refers to the current bundle and the name of it is obviously next because that's the name we gave
to our storyboard.
So now we have our storyboard taking care of the next thing we need is we need to find our view controllers.
So I'm going to say let's next to view controller.
That's true.
Coming next the storyboard died instantiate the view controller with identifiers and identifier for
it was green.
V.S. Aida.
So I'm essentially saying let me format this better.
I'm saying get the next view controller find the view controller that has the idea during VCAT and place
it in next see and once they have that.
That's very simple from this point on.
I can simply say self present view controller or if I wanted to I could actually use a navigation controller
which is what I wanted doing here.
So let's change a little thing as well so let's go ahead to remain a storyboard and say we also have
a navigation controller and that's a good reminder of how we do that.
So Ed embed in a navigation controller so by default or vite view controller or main view controller
is it within a navigation controller.
And this is how we essentially go to a navigation controllers upcoming view controllers.
I'm gonna say self navigation controller DOD push your controller on what am I pushing.
Next we see is it animated.
Of course it is.
And now if I run the application is essentially gonna go find this storyboard find the view controller
I'm pushed an aggregation controller into that view controller.
Let's see if that is what I am suggesting.
I had to go to Green I'm perfect.
If we end up in here using a navigation controller essentially format.
Once again I press that we end up in the green of the next storyboard not even within our own storyboard.
And I've had that by then and the end up within the region of a story or a very handy solution for a
lot of situations where we end up designing or up in multiple storyboards and that's very useful when
you're working with a team of people or if your application is just very very large.
So let's keep all of this in mind and move on to our next lesson.