简体   繁体   中英

MMDrawerViewController objective-c push to navigation view controller

i am beginner iOS dev, I have my app with many controllers. After login on LoginViewController (LoginViewController has segue relation with NavigationViewController) I do init MMDrawerViewController with this code:

-(void)initSidebarController{
    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

    UIViewController *leftView = [mainStoryboard instantiateViewControllerWithIdentifier:@"LeftViewController"];
    UIViewController *centerView = [mainStoryboard instantiateViewControllerWithIdentifier:@"CenterViewController"];


    UINavigationController *leftNav= [[UINavigationController alloc]initWithRootViewController:leftView];
    UINavigationController *centerNav= [[UINavigationController alloc]initWithRootViewController:centerView];

    appDelegate.drawerController= [[MMDrawerController alloc]initWithCenterViewController:centerNav leftDrawerViewController:leftNav];

    appDelegate.drawerController.openDrawerGestureModeMask = MMOpenDrawerGestureModePanningCenterView;
    appDelegate.drawerController.closeDrawerGestureModeMask = MMOpenDrawerGestureModePanningCenterView;

    appDelegate.window.rootViewController = appDelegate.drawerController;
    [appDelegate.window makeKeyAndVisible];
}

Now I want to push DishesViewController on NavigationViewController when user didSelectRowAtIndexPath . How can I do this correctly ?

在此处输入图片说明

在此处输入图片说明 Thanks

Go to the storyboard, select dishesViewController and select the identity inspector from the left pane and in the StoryboardID enter "dishesVC" then use this code :

CateringDishesViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"dishesVC"];
    [self.navigationController pushViewController: animated:YES]

Please follow below step, I am sure it will work for you.

1) Get top ViewController ( Reference link ).

2) If your MMDrawerController library configure is proper then you will get MMDrawerController as a top view controller.

3) Then find center UINavigationController

4) By using center navigation controller you can to new view controller into stack.

If you don't able to do it then provide sample source code with us. So we can provide exact solution.

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