Reputation: 423
I'm using MMdrawerController
for an Objective-C
project and it works well using this hamburger icon on the drawer
to trigger it to open and close. When the drawer
is closed, it rests at the edge of the right side of the screen until it's opened again by clicking the hamburger icon. Now, I would like to make the whole drawer
clickable instead of just the icon, so that the drawer opens wherever I click on it.
Is there a straight forward way to do this, because the only thing I really can think of is creating an invisible button where the drawer
is and make that trigger the open/close code.
The code for triggering the drawer looks like this:
[self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
EDIT
I tried using both touchesBegan
as well as UITapGestureRecognizer
like this:
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
NSLog(@"🐨PRESS");
}
and
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped)];
[self.view addGestureRecognizer:recognizer];
-(void)tapped {
NSLog(@"🐨TAPPED");
}
They only get triggered when the drawer
has already been opened and I press somewhere in the viewController
, but it doesn't trigger when the drawer
is resting to the side of the screen (when it is closed).
Upvotes: 1
Views: 38