0

I have to push a detail view controller when I tap on a tableview cell using with storyboard identifier. I have already designed the view controller. Now i have to navigate to the designed screen by tapping table view cell in the left menu. I am using LGSideMenuController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
if (indexPath.row == 0) {

    ProfileViewController *profileVC = (ProfileViewController*)[mainStoryboard instantiateViewControllerWithIdentifier:PCProfileVC];
    [self.leftMenuVC navigateToViewController:@"profileVC"];
}}

-(void)navigateToViewController:(UIViewController*)viewController{


[(UINavigationController *)[self sideMenuController].rootViewController pushViewController:viewController animated:YES];
[[self sideMenuController] hideLeftViewAnimated:YES completionHandler:nil];}

Please help me to do. Thanks

Sakthi
  • 71
  • 1
  • 8

2 Answers2

0

Why are you pushing viewController in rootViewController. If this code snippet is written in your ViewController.m, then try replacing,

[(UINavigationController *)[self sideMenuController].rootViewController pushViewController:viewController animated:YES];

with

[[self sideMenuController].rootViewController.navigationController pushViewController:viewController animated:YES];

If your identifier PCProfileVC is correct, then this code should work.

Kindly see this link for information on pushing ViewController in UINavigationController.

Sanchit Kumar Singh
  • 513
  • 1
  • 5
  • 17
-1

Try this code :

YourViewControllerClass *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"ViewController"];
 // instanciate your viewcontroller 
    [(UINavigationController *)[self sideMenuController].rootViewController pushViewController:viewController animated:YES]; //push your viewcontroller 
    [[self sideMenuController] hideRightViewAnimated:YES completionHandler:nil]; //hide the menu 
MedAmine.Rihane
  • 1,193
  • 10
  • 17
  • I have not getting any error or crash, but my view not to navigate the respective screen. I am using LGSideMenuController from github – Sakthi Aug 03 '16 at 18:49