I am implementing a UITableView, in which each cell has a UIImageView
subview. I want this UIImageView
to be clickable, so I did the following:
In tableview:cellForRowAtIndexPath
function, when I initialize the cell (when unable to dequeue from used ones), I have following initialization for the imageview:
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(replyTapped:)];
singleTap.numberOfTapsRequired = 1;
[imageView addGestureRecognizer:singleTap];
And the cell's userInteractionEnabled
property is NO since I don't want the entire cell to be selected, like below:
cell.userInteractionEnabled = NO;
And inside the same class, I have this callback defined:
- (void)imageviewTapped:(UISwipeGestureRecognizer* )tap
but it seems like this imageviewTapped
function is never called when I tap on the imageview..
I am wondering if I am doing anything wrong here, and what is a good practice to add TapGestureRecognizer to subview of a cell?
Thank you