Check number of touches in hitTest - Swift

69 Views Asked by At

In my app I have two views, one on top of the other. One of them should receive pinch gestures and, when that gesture is active, also pan gestures. The other, the one below, has to receive pan gestures only.

I've been trying to override hitTest(_ point: CGPoint, with event: UIEvent?) in my top view, to then distinguish when I'm in the first case and when I'm in the other, and let the touch pass accordingly.

As the top view will only handle touches done with two fingers, I've tried to check that in hitTest, but both event?.allTouches and event?.touches(for: UIWindow) return nil. I've also tried to set gesture recognizers to get this info, but of course they are called after hitTest, so I've already lost my opportunity to let the touch pass when I get the info.

My question is, is there any other way of knowing how many fingers is the user using before hitTest? If not, is there any other way of passing the gesture from one view to another?

0

There are 0 best solutions below