Since we know that the image is in a cell and I hate subclassing, we can put together a little fun hack. You can just use the cell.imageView property and toss a category on UIImageView:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
if([self.superview isKindOfClass:[UITableViewCell class]]){
if([touches anyObject].tapCount == 1){
//Image was tapped, issue notification, we use the cell as the object
[[NSNotificationCenter defaultCenter] postNotificationName:@"CellImageTapped" object:self.superview]
//just return after the notification
return;
}
}
//if it wasn't a tap, just forward the touch
[super touchesEnded:touches withEvent:event];
}
Then in the table view controller, you can resolve the selected cell by:
NSIndexPath indexOfSelectedCellImage = [self.tableview indexPathForCell:[notificaton object]];
I didn't check, but the superview of the cell.imageView may be the contentView, in that case just substitute in the following:
…if([self.superview.superview isKindOfClass:[UITableViewCell class]])…
…[[NSNotificationCenter defaultCenter] postNotificationName:@"CellImageTapped" object:self.superview.superview]…
Note: Be sure to have your table view controller subscribe to the notification.