I have a gesture recognizer that dismisses my keyboard but this gets in the way of the tableView didSelectAtRow because the tableView doesn't recognize a tap unless it is a long press. When I run this in the simulator, and tap the tableViewCell lightly, it registers as a tap to dismiss the keyboard and not as a tap to the tableView. However, if I tap and hold for a little longer in the simulator, it will both dismiss the keyboard and register as didSelectAtRow for the tableView. This is similar to question UITableView clicked and no cell selected,but long press trigger cell selected, but I do not know how to use Objective-C. I was wondering if anyone had a workaround to my issue. I was thinking if there was a way to recognize that I tapped in the tableView, that the gestureRecognizer would be cancelled, but I am not sure how to proceed.
Here is what I have so far:
override func viewDidLoad() {
super.viewDidLoad()
searchBar.delegate = self
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(AddressVC.hideKeyboard))
tapGesture.cancelsTouchesInView = false
//searchResultsTableView.addGestureRecognizer(tapGesture)
self.view.addGestureRecognizer(tapGesture)
}
func hideKeyboard()
{
self.view.endEditing(true)
}