I have a couple of UITextField and UIButton inside a UIScrollView and this scroll view is inside a view of my UIViewController. I added a touch gesture recognizer to dismiss the keyboard if shown:
UITapGestureRecognizer *tapToDismissKeyboard = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
[tapToDismissKeyboard setCancelsTouchesInView:NO];
tapToDismissKeyboard.delegate = self;
[self.view addGestureRecognizer:tapToDismissKeyboard];
#pragma mark UITapGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([touch.view isDescendantOfView:self.signupButton_] || [touch.view isDescendantOfView:self.profilePictureImageView_] || [touch.view isDescendantOfView:self.signupUsingFacebook_]) {
return NO; // ignore the touch
}
return YES; // handle the touch
}
The issue is that when I tap the signin/signup button it still detects the tap gesture, in which I actually want the button touch.