What is the cleanest way to detect taps on a UITableView background? I’d like to catch these to dismiss the keyboard.
Unfortunately, when I add a UITapGestureRecognizer to the tableview, tapping the cells fires the handler.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your UI(Table)ViewController or in your UITableView, override
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)eventand if the keyboard is being shown, dismiss it. Also, don’t forget to forward this event to your subviews.