E-Madd
E-Madd

Reputation: 4582

How can I add a UIGestureRecognizer to a UITableViewCell subview?

imgView is a UIImageView that is added as a subview to a custom UITableViewCell class. The action isn't being called when the image is tapped.

[imgView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openMedia:)]];

Upvotes: 2

Views: 2025

Answers (1)

Jason Foreman
Jason Foreman

Reputation: 2146

UIImageView ignores user events by default. You need to enable them with:

imgView.userInteractionEnabled = YES;

Beware, you are also leaking your gesture recognizer.

Upvotes: 15

Related Questions