I am trying to make clickable UIImage, where the user can click it then it'll animate...
i am working with the UIScrollVIew that's why i used the UITapGesture instead of touchesBegan, and it seems that UIGestureRecognizer is not compatible with UIImage...
am i right?
i keep receiving this error message
receiver type 'UIImage' for instance message does not declare a method with selector 'addGestureRecognizer'
is there any other way?
You have to add TapGesture in UIImageView not UIImage
You can response to the tap with the defined selector and do stuff there
You can simply add a TapGestureRecognizer to a UIImageView. You have to use a UIImageView because gesture recognizer are only allowed to be added to views.
You can response to the tap with the defined selector and do stuff there
Try with
UIButton
instead ofUIIMage
and make theUIButton
type custom. And on clicking the same you can show the animation.You have to add the gesture to UIImageView, not UIImage