Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using GestureRecognizer on an ImageView in a scrollview

I have a horizontal, paged scroll view that houses multiple view controllers, each of which contains a UIImageView. Within each view controller, I am adding a Tap GestureRecognizer to the ImageView so I can perform a specific action when the image is tapped/double tapped.

However, the ImageView gesture recgonizers don't seem to be firing, and therefore the selectors are not getting called.

I anticipate it may have something to do with the Imageview's being housed in the scrollview, but I am not sure where to start. Is there anything specific I need to do to ensure that the gesture recognizer gets called for each imageview within the scrollview?

Thanks for your suggestions.

like image 825
SSS Avatar asked Feb 25 '23 19:02

SSS


1 Answers

Perhaps your UIImageView is not configured to receive user interaction

UIImageView has in default userInteractionEnabled set to NO. I would try to change it to YES.

UIgestureRecognizer in a view inside a UIScrollView

like image 130
Sam Avatar answered Feb 27 '23 07:02

Sam