I want to implement TapGestureRecognizer
with the selector
, below is the code where I added tapGestureRecognizer to my imageView
let tapFirstGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(assignImage(_:)))
firstImageView.isUserInteractionEnabled = true
firstImageView.tag = 1
firstImageView.addGestureRecognizer(tapFirstGestureRecognizer)
Here is the action method
func assignImage(_ sender: UIImageView){
imagePicker.allowsEditing = false
imagePicker.sourceType = .photoLibrary
imageViewTag = sender.tag
present(imagePicker, animated: true, completion: nil)
}
Compiler keeps saying
[UITapGestureRecognizer tag]: unrecognized selector sent to instance 0x6080001a7700'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…