Search code examples
iosios6uiviewcontrolleruinavigationcontroller

MMDrawerController navigating centerviewcontroller from sideviewcontrollers with Storyboard setup


I am implementing the MMDrawerController + Storyboard class in my app. Everything is setup correctly and the sidecontrollers are hidden and revealed via methods that are triggered from the centerview controller. What I am having trouble with is navigation of the centerviewcontroller from within the side view controllers. The sideviewcontrollers are tableviewcontrollers and I am just trying to understand the best practice for navigation when a cell is selected from one of the side view controllers. Here is the code I am working with:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.mm_drawerController closeDrawerAnimated:YES completion:^(BOOL finished) {
        [self.mm_drawerController.centerViewController.navigationController popToRootViewControllerAnimated:YES];        
    }];
}

Nothing seems to be happening. All I am trying to do right now is just reset the navigation stack to the top most viewcontroller after the side drawer closes but it doesn't seem to be working. Has anyone else had experience with this kind of setup and can help point me in the right direction? Eventually I want to be able to push different view controllers onto the navigation stack.


Solution

  • Figured it out:

    - (void)tableView:(UITableView *)tableView 
            didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UINavigationController *nav = 
        (UINavigationController *)self.mm_drawerController.centerViewController;
        [nav popToRootViewControllerAnimated:NO];
        [self.mm_drawerController closeDrawerAnimated:YES completion:nil];
    }