In the latest version of iWoman– which I’ve been working on the past few weeks – I had a situation where I am sliding up a date picker when the user taps on a date cell. Sliding it out when the user taps on other cell was easy, you can do that in the other cells’ didSelectRowAtIndexPath. But if you have that in a grouped tableview then there are several areas outside of cells that also could become the targets of a user’s taps.
Generally a user would also assume to be able to dismiss the picker by tapping there, in headers or empty areas where you see the background shine through. In this blog post I’m showing you a technique on how this is done most efficiently and also backwards compatible.
I tried out several approaches before settling on this solution. You might be able to use a gesture recognizer, but that would rule out 3.1 compatibility. You could override the touch methods of the table view and do some fancy detective work there. But I found – as I did so often before – that by far the most convient way is to override hitTest.