I have a bunch of UIButton
s within a UIView
within a UIScrollView
. I\'m trying to add a tap recognizer to the scroll view. The tap rec
For me a combo of the above answers worked
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(userDidTap:)];
tapRecognizer.cancelsTouchesInView = YES;
tapRecognizer.delegate = self;
[tapRecognizer requireGestureRecognizersToFail:self.scrollView.gestureRecognizers];
[self.view addGestureRecognizer:tapRecognizer];
-
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([touch.view.superview isKindOfClass:[UIButton class]] || [touch.view isKindOfClass:[UIButton class]])
{
return NO;
}
return YES;
}