Note that there are some explanatory texts on larger screens.

plurals
  1. POUITapGestureRecognizer - single tap and double tap
    primarykey
    data
    text
    <p>I am trying to add 2 <code>UITapGestureRecognizers</code> to a view, one for single tap and one for double tap events. The single tap recognizer is working as expected (on its own). But I don't seem to be able to get the double tap recognizer working.</p> <p>Have tried to experiment with properties like : <code>cancelsTouchesInView</code>, <code>delaysTouchesBegan</code> and <code>delaysTouchesEnded</code> but still doesn't work.</p> <p>When I double tap, the single tap recognizer would always be activated and the double tap event would also be sent to the super view. But the custom double tap recognizer does not seem to be notified at all.</p> <p>Documentations seem to suggest that the 3 properties mentioned above could be used for the purpose. But I am just not sure what values should be set and on which recognizer(s) (single, double or both). Hope somebody familiar with this could help.</p> <p>The following is the latest updated code block. </p> <pre><code>// ****** gesture recognizers ****** - (void)addSingleAndDoubleTapGestureRecognizersToView:(UIView *)view { // single tap UITapGestureRecognizer *singleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget: tableViewController action: @selector(handleSingleTapOnView:)]; [singleTapRecognizer setNumberOfTouchesRequired:1]; [view addGestureRecognizer: singleTapRecognizer]; // double tap UITapGestureRecognizer *doubleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget: tableViewController action: @selector (handleDoubleTapOnView:)]; [doubleTapRecognizer setNumberOfTouchesRequired:2]; [singleTapRecognizer requireGestureRecognizerToFail: doubleTapRecognizer]; [view addGestureRecognizer: doubleTapRecognizer]; } - (void)handleSingleTapOnView:(id)sender { } - (void)handleDoubleTapOnView:(id)sender { } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload