0

I want to accept single and double taps in my table view cells. I also have tappable labels with hashtags in each of my cells, which I would like to remain clickable. That is a interaction that is seperate and different than what should happen when a user clicks somewhere other than a hashtag.

I noticed that depending on how I word or Google my question I get 2 different answers.

Solution A: UITapGestureRecognizer - single tap and double tap Its accepted answer suggests 2 tap gesture recognizers with delays, and has a high number of upvotes.

Solution B. The other solution I have seen on several threads is implementing a tap counter in tableView:didSelectRowAtIndexPath: combined with a short timer. There are a lot of these threads with this as the accepted answer, but none of them have anywhere near as many upvotes as the answer from solution A.

Is there any argument for why one is better than the other?

The problem here with both solutions is that gestures suck up my attributed labels' taps, and the ...didSelectRow... solution prevents users from tapping multiple cells rapid fire without issues; it is sloppy and leaves room for error.

Community
  • 1
  • 1
ChuckKelly
  • 1,654
  • 4
  • 23
  • 53
  • Did you read even one word of what I wrote? I literally mentioned this EXACT thread and the many variations of it in my question. – ChuckKelly Mar 23 '16 at 10:25
  • The problem here with BOTH solutions is that gestures suck up my attributed labels #hashtag clicks and the didselectrow solution prevents users from liking multiple statuses rapid fire without issues/is sloppy leaves room for error . Closing this would be borderline irresponsible and a abuse of power. Its a well thought out question & real problem. – ChuckKelly Mar 23 '16 at 11:36

1 Answers1

0

you can have 2 Gestures.

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClikOneTap:)];
tapGesture.numberOfTapsRequired = 1;

AND

UITapGestureRecognizer *doubleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClikDoubleTap:)];
doubleTapGesture.numberOfTapsRequired = 2;

With magic Line for control

[tapGesture requireGestureRecognizerToFail:doubleTapGesture];

This has worked very well for me on many occasions.

jose920405
  • 7,607
  • 3
  • 36
  • 64
  • Please re-read including comments, this solution prevents clicks on attributed labels links – ChuckKelly Mar 24 '16 at 01:29
  • I think if we add one view within each cell with the same size of the cell and give the gesture to that view, it probably can work – jose920405 Mar 28 '16 at 13:57