0

I have used SWRevealController in my app.On click of item in UITableView I want to go to a navigation controller so that I can switch between multiple view controllers.But as of now I am not able to redirect to navigation controller.I have used below code but it just replace the controller.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MoreHelpController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"HelpController"];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[navController setViewControllers: @[rootViewController] animated: YES];

[self.revealViewController setFrontViewController:navController];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];

Please tell how can I directly go to navigation controller.It is very confusing here.

Bhavin Ramani
  • 3,221
  • 5
  • 30
  • 41
TechChain
  • 8,404
  • 29
  • 103
  • 228
  • Buddy how can you move to navigation controller??. Navigation controller itself is required to switch between multiple view controllers. – Akash KR Apr 12 '16 at 11:31
  • like method persentviewcontroller & pass the navigation controller – TechChain Apr 12 '16 at 11:36
  • Navigation controller navigates you from one view controller to another view controller. You cannot move like going from one view controller to navigation controller then from navigation controller to view controller. Thats absurd. – Akash KR Apr 12 '16 at 11:39
  • What i mean in my app i want to set one view controller should set as navigation controller – TechChain Apr 12 '16 at 11:46

1 Answers1

0

You just cannot move to navigation controller. Navigation Controller takes you to another view controller from one view controller.

If you want to move to another view controller on selection of table view row, then use didSelectRowAtIndexPath method of tableview and inside that use this:

yourViewController *obj = [self.storyboard instantiateViewControllerWithIdentifier:@"yourViewControllerIdentifier"];
[self.navigationController pushViewController:obj animated:YES];
Akash KR
  • 778
  • 3
  • 11
  • I am not able to get navigation controller because i am using swrevealcontroller.What about setting presentviewcontroller – TechChain Apr 12 '16 at 11:50
  • Follow this tutorial: http://www.appcoda.com/ios-programming-sidebar-navigation-menu/ – Akash KR Apr 12 '16 at 11:52
  • Tell me your requirement, what you actually want to do? – Akash KR Apr 12 '16 at 11:55
  • See i have swrevealcontroller on click of rear_view ie table view item i get new viewcontroller which is again a tableview.on click of tableview i want to go to new view controller & when i press back button then i should be able to see swrevealcontroller – TechChain Apr 12 '16 at 12:01
  • Use the above answer, call your view controller inside didSelectRowAtIndexPath for selected indexPath of row. Your next view controller will appear which has tableview, again use same method you will go to another view controller. – Akash KR Apr 12 '16 at 12:07
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/108931/discussion-between-akash-kr-and-techguy). – Akash KR Apr 12 '16 at 12:07