0

One of my view controllers contains a UITableView with custom UITableViewCell's. My custom UITableView cell contains a UIImageView subview that represents a tappable icon. When the user taps anywhere on the custom cell, except the icon subview, I want my didSelectRowAtIndexPath method to be called like normal. But when my icon subview gets tapped, I want a different method to get called, but I can't figure out how to do this. Do I have capture the touch position in the touchesDidBegin method and manually check if the user tapped the icon? That just feels so hacky. Other, cleaner ideas?

Thanks so much for your wisdom!

BeachRunnerFred
  • 18,070
  • 35
  • 139
  • 238

1 Answers1

0

Simply add a tapGestureRecognizer to the UIImageView in your cell

oiledCode
  • 8,589
  • 6
  • 43
  • 59
  • Then you'll have to add some extra stuff to take care of ignoring the touches you don't want. This isn't completely a duplicate, but I think you'll find the info [here](http://stackoverflow.com/questions/4825199/gesture-recognizer-and-button-actions) useful. – GeneralMike Feb 11 '13 at 21:09
  • But how to do I tell which cell the icon is a subview of? I still need to determine which row of the table was tapped. – BeachRunnerFred Feb 11 '13 at 21:56
  • Nevermind, I just realized the GestureRecognizer has a view property, which I can use to determine which table view cell it belongs to. – BeachRunnerFred Feb 11 '13 at 22:05