开发者

SwipeGesture on ImageView

开发者 https://www.devze.com 2023-02-17 04:44 出处:网络
I am working on an app (its actually a game) that needs to detect Swipe Gestures. When I do swipe on my image view, the image for the image view needs to be changed, but unfortunately it is not workin

I am working on an app (its actually a game) that needs to detect Swipe Gestures. When I do swipe on my image view, the image for the image view needs to be changed, but unfortunately it is not working as expected.

When I add the swipe gesture object to self.view, the desired action is performed whenever I swipe my finger to any location in the view开发者_如何学运维, but I want this action to be performed only when I swipe my finger over the imageView.

On the other hand, when I try to add the swipe gesture to the image view, it doesn't respond to the gesture event.

Please reply if you have the solution to this problem!

Thanks in advance!


It sounds like your UIImageView has userInteractionEnabled set to NO. Try setting yourImageView.userInteractionEnabled = YES and adding your swipe gesture recognizer to the UIImageView.


I too faced the same issue.. The option 'User Interaction Enabled' under Attributes Inspector(available in Inspector window of Interface Builder) was unchecked, Enabling it solved my problem. done using storyboard... Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消