3

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 ?

Santhosh S Kashyap
  • 973
  • 2
  • 13
  • 19

1 Answers1

1

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
Community
  • 1
  • 1
Krunal
  • 77,632
  • 48
  • 245
  • 261