Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Multiple Storyboards in iOS

My objective is to create a tabbed application, then the view for each of the tabs are constructed in separate storyboards.

Storyboard screenshot

My mainstoryboard is a tab view.

Then I create a secondary storyboard (storyboard#2) with 2 View Controllers. The first view controller (also ticked as initial) have a button, and segue (modal) to 2nd view. First view controller

I managed to load the view by subclassing and overriding loadView from storyboard#2. loadView override

Here's the simulator output.

Simulator

When click on the "click me" button, I get a EXC_BAD_ACCESS. The segue does not work, seems like the second storyboard is not being loaded completely.

Has anyone tried to do this before and get it working? There's a youtube video from SkillMaster.net but he does not demonstrate if a segue is working under the secondary storyboard. the video is here: http://youtu.be/D4_twoYvB4M

Thanks for any input and help!

Screenshots:

  • http://www.box.com/s/njnyzjoqg8pnqofv838m
  • http://www.box.com/s/8dqygclmp5ic86e47bi5
  • http://www.box.com/s/k7foe7gpgh2rs3y8gqxd
  • http://www.box.com/s/rym111x7xqxqao51ruip
like image 995
Daddycat Tan Yin See Avatar asked Nov 28 '11 14:11

Daddycat Tan Yin See


People also ask

Can we use multiple storyboards in one application?

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.

How do I use multiple storyboards in Xcode?

On the main storyboard, drag and drop a Storyboard Reference from the object library into the storyboard, then Ctrl + click a button on the main controller -> drag it to the Storyboard Reference -> Select Show. Now we just created a segue between two storyboards.

Can I combine storyboard in SwiftUI?

The answer is YES! Here we will be discussing a simple way to use SwiftUI into our existing project, which already consists of a storyboard. Let's dive in then!


1 Answers

These are the best articles I've seen on multiple storyboards.

  • Storyboard best practices
  • Linking storyboards with segues

Not only does this guy tell you how to create a new storyboard in code, he

  • recommends multiple storyboards in practice (more modular code)
  • discusses when to use xibs vs storyboards (xibs hold views, storboards are based on controllers)
  • provides a class for linking storyboards with segues on github

Note that this last point is important because the key downside of multiple storyboards is that you can't usually link them with segues, but robs library allows that with a bit of fudging

Also see the discussed here

like image 147
Rhubarb Avatar answered Nov 29 '22 14:11

Rhubarb