Search code examples
iosobjective-cxcodemmdrawercontroller

MMDrawerController where I need to add sidemen buttons?


I am junior iOS dev and trying to use MMDrawerController.

I have MainStoryboard with 4 views.

  • NavigationController (embed on CenterViewController controller)
  • CenterViewController
  • LeftViewController
  • AboutViewController

I've added button on Navigation left item on CenterViewController and tap on it open/close my sidemenu.

But if I wan't to change center view with this code

ViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"AboutViewController"];
                if (vc)
                    [appDelegate.drawerController setCenterViewController:vc withCloseAnimation:YES completion:nil];

It works fine but I have no navigation left button. Why?

Thanks


Solution

  • My solution is:

    AboutViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"AboutViewController"];
                if (vc)
                {
                    if ( [appDelegate.drawerController.centerViewController isKindOfClass:[UINavigationController class]] )
                    {
                        [tableView deselectRowAtIndexPath:indexPath animated:YES];
                        UINavigationController *navController = (UINavigationController *)appDelegate.drawerController.centerViewController;
                        [appDelegate.drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
                        [navController pushViewController:vc animated:YES];
                    }
                }