Closed iDev21 closed 11 years ago
What do you mean you're "pushing a view"? Your centerViewController is a navigation controller and you're pushing a new view controller onto it? If so, then all you have to do is [centerViewController popViewControllerAnimated:YES];
. If that's not what you meant then you'll have to explain the situation more clearly.
Thanks for reply. But How to get centerViewController object in pushed view controller??
You would just do:
[self.navigationController popViewControllerAnimated:YES];
I had tried this before I raised the issue. It's not working for me. I have Dashboard View in that a right side bar as MFMenu and after click the button from side bar i pushed a view controller. Now i want go back to Dashboard .
How do i do that?
in the didSelectRowAtIndexPath I simply put this code:
HomeController *Home = [sb instantiateViewControllerWithIdentifier:@"HomeController"];
NSArray *controllers = [NSArray arrayWithObject:Home];
navigationController.viewControllers = controllers;
and voilla it will make you back to the centerViewController.
@xeravim But i dont have UITableView in side menu. I have UIButton and i write below code in it's IBAction method.
SampleViewController VC = [[SampleViewController alloc]initWithNibName:@"SampleViewController" bundle:nil]; UINavigationController navigationController = self.menuContainerViewController.centerViewController; NSArray *controllers = [NSArray arrayWithObject:VC]; navigationController.viewControllers = controllers; [self.menuContainerViewController setMenuState:MFSideMenuStateClosed];
here I did some testing. It seems that your codes are right, so I change the sidemenu to an UIViewController. there are two buttons in my sidemenu. But I am using storyboard here.
- (IBAction)BackToHome:(id)sender {
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:nil];
UINavigationController *navigationController = self.menuContainerViewController.centerViewController;
DemoViewController *loginVC = [sb instantiateViewControllerWithIdentifier:@"DemoViewController"];
NSArray *controllers = [NSArray arrayWithObject:loginVC];
navigationController.viewControllers = controllers;
[self.menuContainerViewController setMenuState:MFSideMenuStateClosed];
}
- (IBAction)toDifferentView:(id)sender {
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:nil];
UINavigationController *navigationController = self.menuContainerViewController.centerViewController;
UIViewController *loginVC = [sb instantiateViewControllerWithIdentifier:@"ViewController"];
NSArray *controllers = [NSArray arrayWithObject:loginVC];
navigationController.viewControllers = controllers;
[self.menuContainerViewController setMenuState:MFSideMenuStateClosed];
}
Maybe you set a wrong nibName, check it again.
Or maybe your SampleViewController not a child from UINavigationController.
Sidebar is one view controller and it's open on PanGesture from Dashboard . in Sidebar view controller i wrote
and calling UIButton IBAction as previous comment and open SampleViewController . Now I want to open Dashboard from sampleviewcontroller's back button.
I checkd XIB name , it's correct .
I can't tell what is going on here. @iDev21 if you want to fork the project and modify one of the demos to replicate this issue I can take a look.
Hello mike , I had solved that issue . If user have multiple UIButton in MFSidemenu which use for navigate to new viewcontroller and if user want navigate to previous view which have have sidemenu than use below code for UIButton IBAction .
NewViewController *newVC = [[NewViewController alloc]initWithNibName:@"NewView" bundle:nil];
UINavigationController *navigationController = self.menuContainerViewController.centerViewController;
[navigationController pushViewController:newVC animated:NO];
[self.menuContainerViewController setMenuState:MFSideMenuStateClosed];
Thanks a lot guys for participating and help . Issue Closed
thank you iDev21 :+1:
Hi
I have a center view controller & have added a right side menu. After pressing a button in the menu, I am pushing a view. How do I pop back to the center view controller from this view?