简体   繁体   中英

How can I push view controller with storyboard identifier using LGSideMenuController?

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

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.

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM