6

I am trying to implement SWRevealViewController Library as given in VideoTutorial, I was successfully able to do that but I don't want everything on 1 storyboard, I want to break it down in 2 storyboards

AppDelegate Code:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    storyboard = UIStoryboard(name: "MenuDrawer", bundle: nil)           
    initialViewController = storyboard.instantiateViewControllerWithIdentifier("SWRevealViewController") as! UIViewController

    self.window?.rootViewController = initialViewController
    self.window?.makeKeyAndVisible()
    return true    
}

Rightnow MenuDrawer storyboard has everything

  1. SWRevealViewCOntroller
  2. TableViewController
  3. NavigationController
  4. RootViewController

and below segues which are defined in Library:

  1. segue1 (sw_rear) : between SWRevealViewController --> TableViewController
  2. segue2 (sw_front) : between SWRevealViewController --> NavigationController

now I want 3 and 4 in different storyboard. but when I move 3 and 4 to different storyboard how do I create segue 2 across storyboards

Victor Sigler
  • 23,243
  • 14
  • 88
  • 105
T_C
  • 3,148
  • 5
  • 26
  • 46

4 Answers4

1

I am not really sure if I understand your problem but you can try this to retrive your second storyboard and load your navigationViewController from there.

let storyBoard : UIStoryboard = UIStoryboard(name: "SecondStoryBoard", bundle:nil)

  let deleteViewController = storyBoard.instantiateViewControllerWithIdentifier("SecondNavigationController") as UINavigationController
Icaro
  • 14,585
  • 6
  • 60
  • 75
1

as far as iknow, you don't need to push again the segue 2 on 3 and 4. what you need is refer the new view (3 and 4) on the segue 2. in Obj-c will be like that:

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
SWRevealViewController *view = [mainStoryboard instantiateViewControllerWithIdentifier:identifier];
[view setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self.navigationController pushViewController:view animated:YES];

where "self" is the ViewController where segue 2 has been created. i hope have answered your question.

Ostanik
  • 104
  • 1
  • 5
1

Try This First Of All Make the other storyboard and add what you need then call the other storyboard in AppDelegate Code:

func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

var storyboard = UIStoryboard(name: "MenuDrawer", bundle: nil)   
var storyboard1 = UIStoryboard(name: "NewStoryBoardName", bundle: nil)          
var initialViewController = storyboard.instantiateViewControllerWithIdentifier("SWRevealViewController") as! UIViewController
var initialViewController1 = storyboard1.instantiateViewControllerWithIdentifier("SWRevealViewController") as! UIViewController

self.window?.rootViewController = [initialViewController,initialViewController1]
self.window?.makeKeyAndVisible()
return true

}
Irshad Qureshi
  • 807
  • 18
  • 41
  • that seems promising, one question do I need to have SWRevealViewController on both storyboards ?? or is it the other RootViewController – T_C Jun 02 '15 at 05:18
  • 1
    u have to put that in both..!! – Irshad Qureshi Jun 02 '15 at 09:58
  • getting 2 compiler errors for line self.window?.rootViewController = [initialViewController,initialViewController2] ........ 1 --> '_??' is not convertible to 'UIViewController' .... 2--> '<>?' is not convertible to 'UIViewController' – T_C Jun 04 '15 at 05:56
1

You can not create segues between storyboards using Interface Builder. It is only possible programmatically, example:

let storyBoardTwo = UIStoryboard(name: "storyBoardTwo", bundle: nil)

// Pick a view controller using it's identifier string set in Interface Builder.
let myVC = storyBoardTwo.instantiateViewControllerWithIdentifier("aViewController") as! UIViewController // Or use more specific (custom) type

// Push it to the navigation controller
self.navigationController.pushViewController(myVC, animated: true)

pushViewControllerwill simply put the myVC on top. This code is what a segue will end up doing. You can put this code anywhere in an existing ViewController, on a button tap IBAction or where ever needed.

If the pushed ViewController have any segues (from Storyboard or code) they will still work, as expected.

This of course works if you would want to programmatically load ViewController from one and the same Storyboard as well.

Mikael Hellman
  • 2,664
  • 14
  • 22