The only working solution I came up with was to use a Category on UIView, that could do my Detail Segues.
@interface UIViewController (SidebarView)
- (void)setupSidebarWithGestureRecognizer:(BOOL)useGestureRecognizer;
- (void)openSettingsPage;
- (void)openAboutPage;
@end
and the .m
-file's code for openAboutPage:
/* This method is called by the sidebar. If the sidebar opens the settings page from itself, the back button
* doesn't know where it should point. This method opens the about menu when the sidebar tells it to, and the back button
* is pointing to the home page. */
- (void)openAboutPage {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *about = [storyboard instantiateViewControllerWithIdentifier:@"About"];
[self.revealViewController rightRevealToggleAnimated:YES];
[self.navigationController pushViewController:about animated:NO];
self.navigationController.navigationItem.title = @"About";
}
and the setupSideBarWithGestureRecognizer... method
- (void)setupSidebarWithGestureRecognizer:(BOOL)useGestureRecognizer {
SWRevealViewController *revealViewController = self.revealViewController;
if (revealViewController) {
UIBarButtonItem *sidebarButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"reveal"] landscapeImagePhone:[UIImage imageNamed:@"reveal"] style:UIBarButtonItemStylePlain target:self.revealViewController action:@selector(rightRevealToggle:)];
self.navigationItem.rightBarButtonItem = sidebarButton;
if(useGestureRecognizer) {
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}
}
}
Then for each page I want to show a sidebar, I just call [self setupSidebar:YES];
in the viewWillAppear
method of that view controller.