iPhone - Didselectrowatindexpath: Only Being Called After Long Press on Custom Cell

iphone - didSelectRowAtIndexPath: only being called after long press on custom cell

same problem happened with me because I have added a tap gesture recogniser over it.
If you have used any gesture recognizer try removing it and check if it causing the problem.

EDIT: Solution as commented by the Ali:
If you have used tap gesture you can use [tap setCancelsTouchesInView:NO];

didSelectRowAtIndexPath called after long press

Try to add uiview in your scroll view and add every elements in that uiview like your tableView,textfield,views and buttons etc.

So, that view works as container view.

Make sure that you are setting proper constraints if you are using autolayout.

Second thing remove unnecessary gesture recognizer implicitly which is not required.

Tableview have scroll enable by default so not need to set it true again. (it's not affect your issue btw!!)

So remove unnecessary configuration and make proper setup and your issue will be solved i think.

Long press only in didSelectRowAtIndexPath

I figured this out. I'd forgotten I had a UIViewController extension that dismissed the keyboard on tap:

extension UIViewController {
func hideKeyboardWhenTappedAround() {
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard))
view.addGestureRecognizer(tap)
}

This was the culprit! Quick fix was to add:

        tap.cancelsTouchesInView = false

right before adding the gesture recogniser. Can't beleive I spent 3 nights on this.

table view date selected only the long press

Since you are using gesture, right before adding the gesture to view, add the following line

tap.cancelsTouchesInView = false // assuming tap is your gesture recogniser variable

didSelectRowAtIndexPath: not being called

I have found the answer. I had a UITapGestureRecognizer set for myTableView's superView. This overrode the selection call. Credit to whoever suggested that that might be it. Your answer was deleted before I could mark it correct.

Set the cancelsTouchesInView property to NO on the gesture recogniser to allow the table view to intercept the event.

-didSelectRowAtIndexPath: not being called

It sounds like perhaps the class is not the UITableViewDelegate for that table view, though UITableViewController is supposed to set that automatically.

Any chance you reset the delegate to some other class?

didSelectRowAtIndexPath not called on Touch

I had faced this general issue so many times.

Please take care of following things

  1. Make sure your cell dont have any type of touch/tap gestures to its contents
  2. Make sure your view dont have any touch/tap gestures applied
  3. Make sure you dont have any View or Table view categories(extension) that has any touch/tap gestures applied [This is more critical as we don`t expect this usually]
  4. Check if you have any third party who works for touch/tap gestures

The most common reasons are gestures on view that prevent the table to get touches on cell.



Related Topics



Leave a reply



Submit