Jelly
Jelly

Reputation: 4532

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.

Upvotes: 0

Views: 492

Answers (1)

Sterling Christensen
Sterling Christensen

Reputation: 865

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.

Upvotes: 3

Related Questions