SWRevealViewController - display control panel from the side menu
I installed my app using SWRevealViewController and it works great, but I want to change how it works. At the moment I have the following views at one level:
- home
- View A
- View B
But I want:
- home
- View A
- View B
I still want Home, View A, View B to be in the menu, but when clicking on View A or View B, it is clicked on Home. And the navbar has a back button instead of a menu button.
Is this possible with SWRevealViewController?
+3
source to share
2 answers
in objective-C
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
SWRevealViewController *main = (SWRevealViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"SWRevealViewController"];
[self presentViewController:main animated:YES completion:nil];
in fast - it automatically opens your SWL root view controller
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let main = storyboard.instantiateViewControllerWithIdentifier("SWRevealViewController") as! UIViewController //SWRevealViewController
self.presentViewController(main, animated: true, completion: nil)
+6
source to share
I found the answer and hopefully this helps someone read this. It has both ways, SideMenu when you have a tabBarController or just a NavigationController. Sending a snippet from the answer that worked for me.
With a TabBar controller:
UITabBarController *tbc = (UITabBarController *)self.revealViewController.frontViewController;
UINavigationController *nc = tbc.selectedViewController;
[nc pushViewController:myVC animated:NO];
[self.revealViewController setFrontViewPosition:FrontViewPositionLeft animated:YES];
With navigation controller:
UINavigationController *frontVC = (UINavigationController *)self.revealViewController.frontViewController;
[frontVC pushViewController: yourVC animated:NO];
[self.revealViewController pushFrontViewController:frontVC animated:YES];
0
source to share