Reputation: 1040
i set a UITapGesture on my scrollView but because of that i can't use the button inside my scrollView... all it reads is the action of the gesture for the scrollView.
how am i gonna able to fix that?
i have this code:
UIGestureRecognizer *tapIt = [[ UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
imgTap = (UITapGestureRecognizer *)tapIt;
imgTap.numberOfTapsRequired = 1;
imgTap.numberOfTouchesRequired = 1;
[scrollView addGestureRecognizer:imgTap];
Upvotes: 0
Views: 264
Reputation: 1406
Try to prevent the touch from reaching the button in the gesture delegate:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
if ([touch.view isDescendantOfView:myButton]) {
return NO;
}
return YES;
}
Upvotes: 3
Reputation: 16774
I believe you can set cancelsTouchesInView property on your gesture to NO. Also there should be some method to ignore gestures in some parts of a view.
Upvotes: 0