Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had the same problem as your first problem: distinguishing double taps from single taps in an <code>MKMapView</code>. What I did was the following:</p> <pre><code>[doubleTapper release]; doubleTapper = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mapDoubleTapped:)]; doubleTapper.numberOfTapsRequired = 2; doubleTapper.delaysTouchesBegan = NO; doubleTapper.delaysTouchesEnded = NO; doubleTapper.cancelsTouchesInView = NO; doubleTapper.delegate = self; [mapTapper release]; mapTapper = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mapTapped:)]; mapTapper.numberOfTapsRequired = 1; mapTapper.delaysTouchesBegan = NO; mapTapper.delaysTouchesEnded = NO; mapTapper.cancelsTouchesInView = NO; [mapTapper requireGestureRecognizerToFail:doubleTapper]; </code></pre> <p>and then implemented the following delegate method:</p> <pre><code>- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { return YES; } </code></pre> <p>Using <code>requireGestureRecognizerToFail:</code> allows the app to distinguish single taps from double taps and implementing <code>gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:</code> ensures that double taps are still forwarded to the <code>MKMapView</code> so that it continues zooming normally. Note that <code>doubleTapper</code> doesn't actually do anything (in my case, except log debug messages). It's simply a dummy <code>UIGestureRecognizer</code> that's used to help separate single taps from double taps.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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