3

I have a standard UITableView which is populated with custom cells which are displayed using a UIImageView. I could tap on the images which would fire the UITableView's method:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

However I wanted to enable pinch zooming on these images which requires nesting the UIImageView in a UIScrollView, so that's what I did. It looks like this:

@interface SMLargeGalleryCell : UITableViewCell
@property (strong, nonatomic) UIImageView *assetImageView;
@property (strong, nonatomic) UIScrollView *scrollView;
@end

However, now when I tap on the images, the UITableView no longer receives a call to didSelectRowAtIndexPath. If I tap BETWEEN the cells, the event will fire. The issue seems to be that the UIScrollView is not forwarding the events.

How can I make this happen?
I'm thinking something along the lines of this (although I know this is ridiculous):

-(IBAction)myScrollViewAction:(id)sender{
   self.scrollView.parentTableView didSelectRowAtIndexPath.....;
}

What am I missing here?
Is this something that has to do with responder chain?

Gabriel.Massana
  • 8,165
  • 6
  • 62
  • 81
VaporwareWolf
  • 10,143
  • 10
  • 54
  • 80

1 Answers1

0

See my answer to the question which seems to be structurally similar to yours: Horizontal UIScrollView having vertical UIScrollViews inside - how to prevent scrolling of inner scroll views when scrolling outer horizontal view?

Shortly my solution was to hack on both:

1) shouldRecognizeSimultaneouslyWithGestureRecognizer of UIGestureRecognizerDelegate protocol.

Using it you can catch gestures on both your tableview and cell simultaneously.

2) Native UIScrollView's panGestureRecognizer.

Since UITableView is a subclass of UIScrollView it should have panGestureRecognizer (and maybe some others) as well.

Just see the pattern I've used - I believe you may transform it to be used in your case.

Community
  • 1
  • 1
Stanislav Pankevich
  • 11,044
  • 8
  • 69
  • 129