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
- Make sure your cell dont have any type of touch/tap gestures to its contents
- Make sure your view dont have any touch/tap gestures applied
- 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]
- 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
iOS Webaudio Only Works on Headphones
Skmutablepayment Property: Applicationusername
iOS 8 Nsinternalinconsistencyexception
Importing Swift Framework into a Objective-C Project
How to Migrate an Old Xcode Project to Use Swiftui
Uiimagejpegrepresentation Has Been Replaced by Instance Method Uiimage.Jpegdata(Compressionquality:)
How to Change the App Store's Large Icon on Itunes Connect
Uirefreshcontrol Stuck After Switching Tabs in Uitabbarcontroller
Xcode 6.4/7 Crashing After El Capitan Beta
(iOS + Storekit) How to Detect When I'm in the Sandbox
How to Check If Haptic Engine (Uifeedbackgenerator) Is Supported
Intercept Request with Wkwebview
Change Uifont in Secure Uitextfield Strange Behaviour in iOS7
How to Keep the Keyboard from Covering My UI Instead of Resizing It
Firebase Retrieving Data in Swift
How to Set Accessibility Identifier in Interface Builder? Xcode4.2