Storyboard reference in Xcode, where should we use it?
UPDATE (January 6, 2016): I just want to quickly mention that using Storyboard references is very simple and is going to help you use Storyboards in a much more clean and maintainable way. A good use case for it is e.g. a UITabBarController
with multiple tabs. Just create one Storyboard for each tab and in your Main.Storyboard
link to those individual Storyboards using Storyboard references. Usage is very straightforward: after creating a Storyboard reference you only need to give it the filename of the individual Storyboard that you want to link to and set the initial view controller within that individual Storyboard. That's it! :)
What follows now is the original answer I gave to @YogeshSuthar's question.
this can be used in cases where you are using multiple storyboards in your app. until now you'd have to instantiate view controllers from other storyboards programmatically, seems like now you can just use this reference and create your segue in the storyboards just like with view controllers from the same storyboard
yes, you connect one view controller from your current storyboard with another view controller from a different storyboard and you can create a segue between these two
yes, this can be used to replace the code that was formerly used to instantiate view controllers from other storyboards programmatically
[UPDATE thx to @AlexBasson] Storyboard references can deployed to iOS 8, OS X 10.10 and watchOS 1.
Usage of Storyboard Reference
Well other answer's are correct to my questions.
And I want to post the usage of the Storyboard Reference
which is used to open View controllers from another storyboard via segue without writing any code. :)
Steps
- First create 1 new storyboard name it anything you want(I named it
NewStoryboard
). - Place your View controller(or any View Controller) in
NewStoryboard
. - Give it a
Storyboard ID
(I have givennewVC
).
- Switch back to your main storyboard.
- Drag and drop
Storyboard Reference
control in this storyboard. - Select the
Storyboard Reference
control and selectAttributes Inspector
. - Select your new storyboard
NewStoryboard
. - Provide Reference ID as
newVC
(which you used inNewStoryboard
storyboard). - Connect this
Storyboard Reference
via segue from ViewController. Now it will open this VC via segue without writing code. :)