Reputation: 1068
Guys, I have table view which displays images so for any image tap opens the image in
didselectrowatIndexpath
So I wanted to add a long press gesture so I added
let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPressed(_:)))
cell.baseview.addGestureRecognizer(longPressGesture)
But each time I press and hold image it is going to didselectrowat method and opening the image instead of going to method longpressed. Is there something I should change for long press gesture action ?
Upvotes: 3
Views: 328
Reputation: 79676
Here is an answer to your question by Apple.
Managing Selections (Responding to Selections)
If the touch occurred in a control embedded in the row, it could respond to the action message sent by the control.Understanding Responders and the Responder Chain
UIKit directs most events to the most appropriate responder object in your app. If that object does not handle the event, UIKit forwards it to the next responder in the active responder chain, which is a dynamic configuration of your app’s responder objects.
Solution:
You have an issue with user interaction of image. Enable user interaction on image view.
cell.baseview.isUserInteractionEnabled = true
Upvotes: 1