10
votes

I've set a Tap Gesture Recognizer in my ViewController via the Storyboard (so all the tap in the view, will hide the keyboard if this one is showed)

The thing is that now, I have add a TableView in this View, and when I clic on a cell, the methode set with the Tap Gesture Recognizer is call, not didSelectRowAtIndexPath.

The "funny" thing, is that if I stay on the cell for 2seconds or more, the delegate didSelectRowAtIndexPath is called, not the TapGestureRecognizer methode.

Could you guys explain what happen here ? where and why am I wrong ?

2
when keyboard will open then add tap gesture and when keyboard will hide then remove tap gesture from the view, this is one way to doJaimish
@Jaimish : I've done that, it work perfectly for the TapGestureRecognizer method, but now, on my TableView, nothing is called when I single tap on a cell, and didSelectRowAtIndexPath is called when I stay press on the cell for 2secondes or more, I still wonder why.Vincent 'On-arap' Burel
You have tried the @Jan Greve answer?Jaimish
Provide some code of Textfield or Textview delegate and also didselect method of tableviewJaimish

2 Answers

20
votes

Your UITapGestureRecognizer probably cancels the touch event when successfully recognizing a touch.

Try setting

tapGestureRecognizer.cancelsTouchesInView = NO;

For a more thorough read on this topic, have a look an the conceptual docs on gesture recognition.

-3
votes

Better way is don't use didSelectRowAtIndexpath method.

if you have to implement gestures on table view cell then create tap gesture in cellForRowAtIndexpath and using tag identify particular cell click.