Reputation: 85
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.
Upvotes: 1
Views: 1722
Reputation: 211
I guess you are trying to call UINavigationcontroller of your UINavigationcontroller
revealViewController().frontViewController gives me UINavigationcontroller already
I have this in side menus controller and its working
override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
var controller: UIViewController?
var navController: UINavigationController?
if identifier.hasSuffix("Orders") {
controller = self.storyboard?.instantiateViewController(withIdentifier: "ShowOrdersViewController") as! ShowOrdersViewController
(controller as! ShowOrdersViewController).orderType = identifier
navController = revealViewController().frontViewController as! UINavigationController
}
self.revealViewController().revealToggle(animated: true)
navController?.pushViewController(controller!, animated: true)
return false
}
Upvotes: 0
Reputation: 2283
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];
}
Upvotes: 1