0

I have an application implementing a side menu in swift. (http://www.appcoda.com/sidebar-menu-swift/)

I implemented 3D touch shortcut, quick actions, it almost works.

The problem is I arrive directly on my view without instantiate revealViewController(), with the following code:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let navVC = storyboard.instantiateViewControllerWithIdentifier("newsViewController") as! UINavigationController
self.window?.rootViewController?.presentViewController(navVC, animated: true, completion: nil)

I don't know how/where is instantiated revealViewController().

I have:

self.revealViewController() == nil 

What happens now is the menu doesn't want to open.

Thank you for your help :-)

papay0
  • 1,311
  • 1
  • 12
  • 25

4 Answers4

2

You can found your answer as this link: How to push viewcontroller from appdelegate in storyboard

I Worte code as below It works for me.

    UIStoryboard *st = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    SWRevealViewController *mainRevealController = [[SWRevealViewController alloc] init];
    CaseCollectionViewController *descController = (CaseCollectionViewController*)[st instantiateViewControllerWithIdentifier: @"CaseCollection"];
    descController.selectedLevel = @"pll";
    descController.title = @"PLL";

    //UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:descController];
    UINavigationController *frontNavigationController = (UINavigationController*)[st instantiateViewControllerWithIdentifier: @"NavigationViewCtrl"];
    [frontNavigationController setViewControllers:@[descController]];
    SidebarTableViewController *rearViewController = (SidebarTableViewController*)[st instantiateViewControllerWithIdentifier: @"SideBarView"];
    mainRevealController.rearViewController = rearViewController;
    mainRevealController.frontViewController = frontNavigationController;
    self.window.rootViewController = mainRevealController;
Community
  • 1
  • 1
김영호
  • 41
  • 2
1

For those who want to do it with Swift:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let frontNavigationController = storyboard.instantiateViewControllerWithIdentifier("planningViewController")
let rearNavifationController = storyboard.instantiateViewControllerWithIdentifier("menuViewController")
let mainRevealController : SWRevealViewController = SWRevealViewController(rearViewController: rearNavifationController, frontViewController: frontNavigationController)
self.window?.rootViewController? = mainRevealController
Pang
  • 9,564
  • 146
  • 81
  • 122
papay0
  • 1,311
  • 1
  • 12
  • 25
0

In Order to get your reveal ViewControlled you must make it as InitialViewController in storyboard, don't need to write any code in Appdelgate.

You can find the best example in git hub storyboard example or set up like below screen shot enter image description here

Akshay
  • 227
  • 2
  • 13
  • The problem is when I use 3D Touch quick actions, the application goes directly in my view I selected with quickActions, and so the application does not go neither through sw_rear nor sw_front. How can I solve that? – papay0 Oct 31 '15 at 14:32
0

Objective-c code for deep linking.It will open the home with side menu and will push the home (front viewcontroller) to the notification viewcontroller.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *frontViewControllerNav = [storyboard instantiateViewControllerWithIdentifier:@"homeNav"];// navigation controller of home screen..
UINavigationController *rearViewControllerNav = [storyboard instantiateViewControllerWithIdentifier:@"sideMenuNav"];//navigation controller of menu screen..

SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearViewControllerNav frontViewController:frontViewControllerNav];
revealController.delegate = self;
UIViewController *notificationView=[storyboard instantiateViewControllerWithIdentifier:@"notificationVC"];
[frontViewControllerNav pushViewController:notificationView animated:NO];
revealController.bounceBackOnOverdraw=NO;
//revealController.stableDragOnOverdraw=YES;
self.window.rootViewController = revealController;
abhimuralidharan
  • 5,752
  • 5
  • 46
  • 70