Implementation of the SWRevealViewConroller library (drop-down menu) in several storyboards

I am trying to implement the SWRevealViewController Library as stated in the VideoTutorial , I was able to do this, but I do not want everything on one storyboard, I want to break it into 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 Schedule Has It All

  • SWRevealViewCOntroller
  • Tableviewcontroller
  • NavigationController
  • Rootootcontroller

and below the segues that are defined in the library:

  • segue1 (sw_rear) : between SWRevealViewController --> TableViewController
  • segue2 (sw_front) : between SWRevealViewController --> NavigationController

now i want 3 and 4 in a different storyboard. but when I move 3 and 4 to different storyboards, how do I create segue 2 through the storyboard

+6
source share
4 answers

I'm not sure if I understand your problem, but you can try this to extract a second scenario scene and load your navigation controller.

 let storyBoard : UIStoryboard = UIStoryboard(name: "SecondStoryBoard", bundle:nil) let deleteViewController = storyBoard.instantiateViewControllerWithIdentifier("SecondNavigationController") as UINavigationController 
+1
source

as far as I know, you do not need to press segue 2 again on 3 and 4. what you need is a new view (3 and 4) in step 2. in Obj-c it will be the same

 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 was created. I hope you answered your question.

+1
source

Try this first. Make another storyboard and add what you need, then call another storyboard in the 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 } 
+1
source

You cannot create a segue between storyboards using Interface Builder. This is only possible programmatically, for example:

 let storyBoardTwo = UIStoryboard(name: "storyBoardTwo", bundle: nil) // Pick a view controller using it 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) 

pushViewController simply put myVC on top. This code is what segue will do. You can place this code anywhere in your existing ViewController, on the Tap IBAction button, or where necessary.

If the clicked ViewController has any segments (from the storyboard or code), they will still work as expected.

This, of course, works if you want to programmatically load the ViewController from the same storyboard.

+1
source

Source: https://habr.com/ru/post/988061/


All Articles