Add the UITapGestureRecognizer identifier to the imageView.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.imageView.image =
UITapGestureRecognizer *tapGesture = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)] autorelease];
[cell.imageView addGestureRecognizer:tapGesture];
cell.imageView.userInteractionEnabled = YES;
}
}
- (void)imageTapped:(UITapGestureRecognizer *)gesture {
UITableViewCell *cell = [[[gesture view] superview] superview];
NSIndexPath *tappedIndexPath = [self.tableView indexPathForCell:cell];
NSLog(@"Image Tap %@", tappedIndexPath);
}
source
share