I added UIImageView
in superview then add required gestures and works fine but when doing the same in another UIView
(add UIImageView
in UIView
and add gestures) it does not work I think it's about delegates but I can't figure it out.
Code in Swift please.
Add UIGestureRecognizerDelegate
Ex-
self.imgView.isUserInteractionEnabled = true
self.view.isUserInteractionEnabled = true
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped))
imgView.addGestureRecognizer(tapRecognizer)
Add Gesture you want on UIView or ImageView
func imageTapped(gestureRecognizer: UITapGestureRecognizer)
{
let tappedImageView = gestureRecognizer.view!
let imageView = tappedImageView as! UIImageView
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.