Dismiss keyboard by touching background of UITableView
问题 I have a UITableView with UITextField s as cells. I would like to dismiss the keyboard when the background of the UITableView is touched. I\'m trying to do this by creating a UIButton the size of the UITableView and placing it behind the UITableView . The only problem is the UIButton is catching all the touches even when the touch is on the UITableView. What am I doing wrong? Thanks! 回答1: This is easily done by creating a UITapGestureRecognizer object (by default this will detect a "gesture"