MMDrawerController icon indicating copy to clipboard operation
MMDrawerController copied to clipboard

How do I push from the center viewcontroller?

Open kkendall33 opened this issue 13 years ago • 5 comments

Sorry to bug, again... I want to push from the center viewcontroller. When I do (one of) the following, I can't swipe to view the left side view, when I normally can.

[AppDelegate.navigationController pushViewController:aVC animated:YES]; [AppDelegate.drawerController.navigationController pushViewController:aVC animated:YES]; [AppDelegate.drawerController.centerViewController.navigationController pushViewController:aVC animated:YES];

This is how I have things setup in my app delegate:

self.drawerController = [[MMDrawerController alloc] initWithCenterViewController:centerViewController leftDrawerViewController:leftSideDrawerViewController rightDrawerViewController:nil];

self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.drawerController];

Thank you for the help!!!

kkendall33 avatar Aug 27 '13 02:08 kkendall33

self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.drawerController];

I don't think you want to have that there. The drawer controller should be the rootviewcontroller of the application window. You then add your center view and left view to the drawer. You can make the left and right side contain a uinavigation controller, which embeds your left/center view controller. Then simply call [centerViewControlller.navigationViewController pushViewController:avc animated:YES]

There's no need to call your app delegate. If you are pushing from within the code of your center controller, this will do: [self.drawerController.centerViewControlller.navigationViewController pushViewController:avc animated:YES]

mmarszal avatar Aug 29 '13 11:08 mmarszal

@kcharwood I am having similar issue.... I am trying to push to centerViewController and it would not work.

[centerViewControlller.navigationViewController pushViewController:avc animated:YES]

simply setting centerViewController to a different ViewController or NavigationCotroller works well. But pushing does not work.

simplyi avatar Jun 03 '14 19:06 simplyi

@simplyi I was having an issue like this until I realized that my centerViewController is itself a UINavigationController, so instead of [centerViewController.navigationController pushViewController:avc animated:YES]; you would just do [((UINavigationController *) centerViewController) pushViewController:avc animated:YES];

fraggle222 avatar Sep 29 '14 11:09 fraggle222

I want to push a view controller from MMDrawerController, in drawer i've used table view and didselect method is used to navigate to other controller but it doesn't showing navigation bar in that controller please help me. Here is the code I tried in didselect method:

if (self.currentIndex == indexPath.row) {
    [self.mm_drawerController closeDrawerAnimated:YES completion:nil];
    return;   
}
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
                                                         bundle: nil];
UIViewController *vc ;
vc.navigationController.navigationBarHidden = FALSE;
vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"AlbumVC"];

if (vc) {
    self.currentIndex = indexPath.row;
    [self.mm_drawerController setCenterViewController:vc withCloseAnimation:YES completion:nil];    
} else {
    [self.mm_drawerController closeDrawerAnimated:YES completion:nil];
}

GopalPatel1989 avatar Jun 30 '16 11:06 GopalPatel1989

right now you are pushing a view without navigation controller, so no nav bar... you need to push a navigation controller whose root view controller is your view controller.

so In your storyboard, rename your actual view Controller id "MainContent" and add a navigation controller whose Id is named Main, and which rootController is your viewController "mainContent"

SWLNavigationController* viewNavCtrl = [mainStoryboard instantiateViewControllerWithIdentifier:@"Main"];    
if (viewNavCtrl)
 [self.mm_drawerController setCenterViewController:viewNavCtrl withCloseAnimation:YES completion:nil];
...

altagir avatar Jun 30 '16 14:06 altagir