I want to implement TapGestureRecognizer
with the selector
, below is the code where I added tapGestureRecognizer to my imageView
The problem is with your method declaration and with assigning tag
to the object of UIGestureRecognizer
. Change your method declaration like this.
func assignImage(_ sender: UITapGestureRecognizer)
Or
func assignImage(_ sender: UIGestureRecognizer)
Edit: To access imageView object with UITapGestureRecognizer
.
func assignImage(_ sender: UITapGestureRecognizer) {
if let imageView = sender.view as? UIImageView {
}
}
Note: You need to set tag
with you imageView
not with you UITapGestureRecognizer