Reputation: 27
Is it possible to cancel a UIGestureRecognizer
when I tap on a button?
Upvotes: 2
Views: 757
Reputation: 1760
Yes you can. You can add it and remove, by this code.
-(IBAction) YourButtonAction {
some code, that your button must to do
self.yourButton removeGestureRecognizer: (yourRecognizer);
}
Upvotes: 0
Reputation: 11276
Try this method :
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return whateverYouWant;
}
Upvotes: 0
Reputation: 571
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
// test if our control subview is on-screen
if([gestureRecognizer isMemberOfClass:[UITapGestureRecognizer class]]){
if ([touch.view isKindOfClass:[UIButton class]]) {
return NO; // ignore the touch
}
}
return YES; // handle the touch
}
Upvotes: 9