Pradumna Patil Pradumna Patil - 2 months ago 7x
Objective-C Question

MVYSideMenu pop to root viewcontroller

I am using MVYSideMenu in my application and I can present new controller using "changeContentViewController" of MVYSideMenu but it presents new controller so from here I want to pop back to my root(HomeViewController) so I have done lot of research on this but couldn't find solution.

So if anybody knows the solution please help me.
Thanks in advance.


MVYSideMenu is making rootViewController, when you are trying to open any view from this. If you are making rootViewController, then you can not able to pop from that.

So if you want to go back, then you have to Push that view instead of making rootViewController.

I think, Right Now you are using following code for open any controller for side menu:

ChildViewController *contentVC = [[ChildViewController alloc] initWithNibName:@"ChildViewController" bundle:nil];
appDelegate.nav = [[UINavigationController alloc] initWithRootViewController:contentVC];
[[self sideMenuController] changeContentViewController:appDelegate.nav closeMenu:YES];

So Please use following code instead of above code. Here nav is object of UINavigationController in AppDelegate.

ChildViewController *contentVC = [[ChildViewController alloc] initWithNibName:@"ChildViewController" bundle:nil];
[appDelegate.nav pushViewController:contentVC animated:YES];
[[self sideMenuController] changeContentViewController:appDelegate.nav closeMenu:YES];

So You can able to push any view from side menu. And Now just try to pop this view. I am sure that you can able to pop this view after using this.

Make sure that, If you do this, then may be memory leakage is there. Because all times viewControllers are adding to the navigation controller. So My suggestion is, don't do this, if you can convince your client. :) Otherwise, you can make your own side menu.

Hope, this is what you're looking for. Any concern get back to me. :)