UITapGestureRecognizer selector, sender is the gesture, not the ui object

dysan819 picture dysan819 · May 21, 2011 · Viewed 31.9k times · Source

I have a series of imageviews that I identify using their tag. I have added a single tap gesture to the images.

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectImage:)];
[tableGridImage addGestureRecognizer:singleTap];
tableGridImage.userInteractionEnabled = YES;
[singleTap release];

This manages to call the selectImage selector ok, but passes the gesture as the sender. I need the imageview as the sender so I can get the tag.

Any ideas on how I can get the imageview and it's tag?

Answer

dysan819 picture dysan819 · May 22, 2011

I figured out how to get the tag, which was the most important part of the question for me. Since the gesture is the sender, I figured out the the view it is attached to is sent along with it:

[(UIGestureRecognizer *)sender view].tag

I am still curious if anyone can tell me how to send an argument through a UITapGestureRecognizer selector.