3

I am working on an iOS app and I want to split it into a couple of Storyboards, the problem is that I can't seem to figure out a way to setup references between Storyboards as an entry point.

For example I want my Main.storyboard to look something like this:

--> Authentication Storyboard --> Tabbed Storyboard --> ...

I am new to iOS development and I would expect this to be simple, but can't seem to find a way to do it.

Jeehut
  • 20,202
  • 8
  • 59
  • 80
dk87
  • 53
  • 5
  • you want more than one storyboard, like Login.storyboard, Main.storyboard, and you are confused how to call Controllers from different storyboards? – Chatar Veer Suthar Apr 17 '16 at 11:20

3 Answers3

2

Yes you can use multiple Storyboards in a project BUT No, you cant reference them directly from inside another storyboard.

Referencing a Storyboard to use on launch

Your project target can use any of the storyboards contained within it. The reference for the storyboard entry point can be found in the target settings.

enter image description here

  1. Select the target
  2. Select the General Tab
  3. In the dropdown for main interface select which storyboard to use initially.

Referencing a Storyboard in code

So in this example I wish to push a viewcontroller onto a navigation Controller. The viewcontroller I want to reference may be in a different storyboard or the current one I'm using. The code doesn't care...

    if let storyboard = UIStoryboard(name: "A2ndStoryboard", bundle: nil) {
      if let vc = storyboard.instantiateViewControllerWithIdentifier("SomeViewController" as String) {

        navigationController?.pushViewController(vc, animated: true)
      }
    }

When you want to reference ViewControllers like this you need to ensure that they are identified in the Storyboard correctly:

enter image description here

Damo
  • 12,840
  • 3
  • 51
  • 62
  • This is exactly what I need. I had the wrong Idea that Main storyboard is required to be starting point. Thanks. – dk87 Apr 17 '16 at 12:50
1

Dont use multiple storyboards. use one storyboard with multiple viewcontrollers with segue between them and embed navigationcontroller. for exa, use one viewcontroller for Authentication like wise another viewcontroller for tabs (tabbarviewcontroller). give segue from authenticationVC to tabbarVC. hope this will help. :)

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
0

As you say you're new to iOS development let me try to recap this for you:

Interface Builder (IB) is a tool built in to Xcode that helps you design your user interface without any code. Everything IB can do can also be done programmatically. IB supports two different types of files: XIB files and Storyboards.

XIB files (extension .xib) are collections of UIView objects that you can design using IB.

Storyboards (extension .storyboard) are collections of UIViewController objects which all have a view property that you can design using IB.

Conlusion: There (currently) is no such thing as an Interface Builder file type which represents a collection of XIBs or Storyboards. Therefore you can't reference a Storyboard within a Storyboard as of now. Instead you can still split your view controllers up into different Storyboards and transition between them programmatically.

Here's another thread on SO to help you get started with the programmatic transitions:

How can I load storyboard programmatically from class?

I hope this helps.

Community
  • 1
  • 1
Jeehut
  • 20,202
  • 8
  • 59
  • 80
  • Thank you for this breakdown, it has helped me to better understand how the storyboards are supposed to work. The accepted answer had a concrete solution and that is why I accepted it, though I would accept both. – dk87 Apr 17 '16 at 13:33