Using Storyboard Reference

1.6k views Asked by At

How to use Storyboard reference to connect 2 storyboards? Is it possible to connect storyboard with xib file? I want to use it via Navigation Controller.

3

There are 3 answers

1
Omar Barrera Peña On BEST ANSWER

if you want to reference two storyboards in Xcode 7, in your initial storyboard select the view controllers you want to use in the second storyboard, in the task bar select "Editor" and then "Refactor to Storyboard", then you have to name the new storyboard and thats all, i don´t know if you can reference to an .xib file, notice that you can use the storyboard reference to call a view even in the same storyboard or even a view that is not connected to any other view, and in the reference you can specify which view you want to load (you do this in the identity inspector), or leave that space empty and the view loaded will be the initial view.

Better explained step by step:

If you want to create the new storyboard at the same time

  • select the views you want to move to the new storyboard
  • open the Editor's menu and select Refactor to Storyboard
  • Xcode will ask you the name you want to give to the new storyboard and thats all

If you have already created the storyboard

  • Open the storyboard where you want to call the second storyboard
  • drag the Storyboard Reference that is located in the objects library
  • select the reference you added and open the identity inspector
  • in the identity inspector write the name of the storyboard that you want to call (required) and the storyboardID of the view you want to load (optional)

thats how you use storyboard references in Xcode 7, hope that is useful to you

1
Suhit Patil On

You can load another storyboard simply like this your main storyboard..just replace the name of storyboard and viewcontroller

 UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"NewStoryboard" bundle: nil];  
 SomeViewController *someViewController = [storyboard instantiateViewControllerWithIdentifier:@"SomeViewController"];
[self presentViewController:someViewController animated:YES completion:nil];

or Swift

let storyboard = UIStoryboard(name: "NewStoryboard", bundle: nil)
let someViewController = storyboard.instantiateViewControllerWithIdentifier("SomeViewController") as! UIViewController
self.presentViewController(someViewController, animated: true, completion: nil)
0
Rein rPavi On

Hi Friend this is really easy,

Just create a new Storyboard with file>newfile and get the new Storyboard from User Interface don't forget to name it properly ;)

Drag a Storyboard reference to your main story board and now connect it with button or navigation bar button or tab bar whatever (as per your requirement)and thats it...

Select Storyboard reference and go to Attribute Inspector you can see the dropdown of story board from that select your new Storyboard.

Create any new view controller in the empty Storyboard and make it initial view controller.

Run the code

This is how you do it my friend hope it helps :) Tell me if you are not able to solve will update my answers with screen shots.