Search code examples
iosswiftuinavigationcontrollerswrevealviewcontroller

SWRevealViewController push to actual navigation controller


I'm working with SWRevealViewController and I want to push a view controller from my menu view controller to actual navigation view controller. The problem is, when I use self.revealViewController().frontViewController.navigationController! this navigation Controller is always nil and should't be, because I always pushFrontViewController with navigation controller.

Any point how to push on actual navigation controller? I'm working with storyboards.


Solution

  • Here's your solution

    From Menu to Normal ViewController by using Swrevealviewcontroller "setFrontViewPosition"

    In Swift

            let obj = self.storyboard?.instantiateViewControllerWithIdentifier("ViewController") as! ViewController
            let navController = UINavigationController(rootViewController: obj)
            navController.setViewControllers([obj], animated:true)
            self.revealViewController().setFrontViewController(navController, animated: true)
            self.revealViewController().setFrontViewPosition(FrontViewPosition.Left, animated: true)
    

    In Objectctive-c

     -(void)main{
         LoginViewController *tar = [self.storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
         UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:tar];
         [navController setViewControllers: @[tar] animated: YES];
    
        [self.revealViewController setFrontViewController:navController];
        [self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
    }