I have a UIView with an UITapGestureRecognizer and on top I use textFields and checkboxes. I want to use this gestureRecongizer to remove the keyboard by clicking anywhere else.
But know my checkboxes call the selector of the recongizer?
How can I avoid this behavior?I already tried the exclusiveTouch property but it didn’t work.
Anyone who can recommend me a good workflow for this problem?
1- Register as your recognizer delegate
tapRecognizer.delegate = self;(declare that you are UIGestureRecognizerDelegate)2- Implement shouldReceiveTouch
3- Check the touch.view to decide if the gesture should take care of that touch. In you case, return NO if its the checkbox view.
(You dont have to use isKindOfClass, You can use any other way to determine if its your checkbox)