Hi,
I am trying to have two distinct actions: single tap and double tap (two quick taps). What happens though is that both actions get called. Is there a way around this?
Thanks.
Hi,
I am trying to have two distinct actions: single tap and double tap (two quick taps). What happens though is that both actions get called. Is there a way around this?
Thanks.
Drop 2 TapGestures and in the double ones set "Taps Required" to 2 in the Inspector.
Hi @marco. I did this already but when I double tap (at least in the simulator), it also triggers the one tap Action event.
Also, the one tap conflicts with swipe up for instance, as swiping requires tapping and swiping.
Any solution?
Hi @ingurgite
we'll do our best to add a way to fire a gesture (in your case the single-tap) only when another gesture fails (in your case the double-tap) in the next release.
@ingurgite
A new function for the gesture recognizer objects, named requireToFail()
, will be available in the next release.
You will be able to add the following code in the WillShow
event of the container of the two tap gestures:TapGesture1.requireToFail(TapGesture2)
(where TapGesture1
is the single-tap and TapGesture2
is the double-tap)
Thanks a lot @andrea. Out of curiosity, when do you think the next release will be out?
Best.
@ingurgite, the new official release will be available in about two weeks.
In the meantime, you could try the new beta release that includes this new method:
Creo build18340
Thanks Andrea. It works. It's great.
However, this beta version crashes every time I stop the simulator :(
thank you for your feedback, we'll check this issue
Hi @andrea, I am coming back to you as it seems the requireToFail() functionality is not yet in the stable release. Can you confirm or did something change?
Thanks.
Hi @ingurgite , the `requireToFail()` method is included in the newly released version and it is documented in the superclass documentation: UIGestureRecognizer
Thanks.
Hi @andrea, the solution you proposed worked for weeks but it no longer works in the simulator right now for me.
This is what I do. Again it works on a real iOS device, if I comment those lines or 4 out of 5, it will work, though the action will take almost a second to react.
forward.requireToFail(inspect) forward.requireToFail(back) forward.requireToFail(later) forward.requireToFail(previous) forward.requireToFail(next)
Thanks.
Hi @ingurgite,
the `requireToFail` is not working correctly in our simulator if used for more than one gesture recognized, this bug will be fixed in the next release. It should work fine on a real iOS device.
There could be a delay for the action to be invoked depending on the gesture recognizer added as `requireToFail` because the first gesture recognizer must wait for the other gesture to fail before changing to the recognized state.