I want to handle a tap in a UITableView
not including the cells. In other words, the headers and footers.
I can add a gesture recognizer to the headers (there are no footers), but the space at the bottom of the last section does not respond to a tap.
Instead of adding the gesture recognizers above, I tried adding a gesture recognizer to the table, but it prevents tableView:didSelectRowAtIndexPath:
being called.
I tried all sorts of UIGestureRecognizerDelegate
calls with not much luck.
I finally got that to work by setting cancelsTouchesInView = NO
on the recognizer (I think this was the secret) and implementing gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
in the delegate so that the tableView
got touches and called tableView:didSelectRowAtIndexPath:
The handler has to filter out taps on the cells, but at least it works. (Also, found a bug in UITableView
indexPathForRowAtPoint:point
which returns invalid indexPaths
sometimes.)
My question is: Is there a better way of getting the cell views to prevent touches/gestures getting through to the table? (I will post code if nobody gives me any better ideas.)