简体   繁体   中英

UIView handle only double tap

I want my view to handle only double tap gestures. The rest of the gestures should be forwarded to its superview. How could this be achieved? I tried the pointsInside override trick but it forwards all the touches.

Edit:

Also the superview may or may not decide to handle the touches (it might decide to forward them to other views). Actually what I am trying to achieve is to have a UIWindow over the initial one that reacts only to double tap, the rest of the touches should pass through.

Add your double tap gesture recognizer to the super view, then in the gesture recognizer's delegate implement gestureRecognizerShouldBegin and return true only if it's within the frame of your view. This way you can set userInteractionEnabled to false on your view and everything will work. The view will be transparent to touches, except double taps. No need for any hitTest or pointInside overrides.

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