Reputation: 2435
I am using SWRevealController
in my application and have followed the instructions described here: http://www.appcoda.com/ios-programming-sidebar-navigation-menu/
However it appears that the sidebarButton
does not fire the toggle
I have set it up as follows:
Initial View Controller class has been set to SWRevealViewController
Segue has been created linking it to the NavigationViewController
and the segue has been given the identifier sw_front
I have a menuViewController
that is subclassed from UITableViewController
I created a segue from the Initial view Controller whose class is SWRevealViewController
to the menuViewController
and gave that segue an identifier sw_rear
In mainViewController.m
I have imported SWRevealViewController.h
and I have set the menu button
@property (weak, nonatomic) IBOutlet UIBarButtonItem *sidebarButton;
In mainViewController in the viewDidLoad method I have the following:
SWRevealViewController *revealViewController = [self revealViewController];
if ( revealViewController )
{
[self.sidebarButton setTarget:self.revealViewController];
[self.sidebarButton setAction: @selector(revealToggle:)];
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}
When I run the application and put a breakpoint at the point where I am setting the target and Action for button I can see that they are being assigned.
However when I click the button the revealViewController.revealToggle
method is not firing.
I was wondering if maybe I need to set up the event that fires it - as in for a touchupInside
event. But I've looked through all the sample code https://github.com/appcoda/Slideout-Sidebar-Demo/tree/master/SidebarDemo and can't see where they have done that. I'm at a loss to figure out why the revealToggle action is not firing.
Many thanks for any suggestions
Upvotes: 1
Views: 984
Reputation: 380
You need to put the button on the action on @property (weak, nonatomic) IBOutlet UIBarButtonItem *sidebarButton;
You can see an example of this one https://github.com/John-Lluch/SWRevealViewController/tree/master/RevealControllerStoryboardExample2
Upvotes: 1