I have a UITableViewCell
class named CommentsTableViewCell
which among other things includes a UIImageView
and a UILabel
.
You need to create two UITapGestureRecognizer
object because UITapGestureRecognizer
works with single UI
element object. So create second TapGestureRecognizer
and assign one to UILabel
and one to UIImageView
.
From UIGestureRecognizer
documentation.
A gesture recognizer operates on touches hit-tested to a specific view and all of that view’s subviews. It thus must be associated with that view. To make that association you must call the UIView method
addGestureRecognizer(_:)
. A gesture recognizer doesn’t participate in the view’s responder chain.