简体   繁体   中英

not allow tap gesture on UIImageView when other finger already on other UIImageView

I have one UIView. in that there are more than one UIImageViews. and i added tapgesture in all that UIImageView individually. so i have to not allow tap gesture function called when tap on UIImageView when other finger is already on other UIImageView. any help appreciate.

您必须实现UIGestureRecognizerDelegate方法gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:并返回NO

Have you tried to set the UIView multipleTouchesEnabled to NO? You can also try to subclass the UIImageView and override the following methods, so you can control the state and forbid additional touches to be executed.

– touchesBegan:withEvent:

– touchesMoved:withEvent:

– touchesEnded:withEvent:

– touchesCancelled:withEvent:

add a unique tag to all images you have

when your tapgesture selector is called, check for the tag, if it matches the tag of the image you are interested in, then go ahead with what you want to do, else do nothing

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM