Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6373071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:19:05+00:00 2026-05-25T01:19:05+00:00

i am trying to implement my own gesture recognizer in addition to the one

  • 0

i am trying to implement my own gesture recognizer in addition to the one already used by the MKMapView. Right now i can tap on the map and set a pin. This behavior is realized by my UITapGestureRecognizer. When i tap on a pin that already exists, my gesture recognizer does nothing, but instead the callout bubble of this pin is shown. The UIGestureRecognizerDelegate looks like this:

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if (gestureRecognizer == self.tapRecognizer) 
    {
        bool hitAnnotation = false;
        int count = [self.mapView.annotations count];
        int counter = 0;

        while (counter < count && hitAnnotation == false ) 
        {
            if (touch.view == [self.mapView viewForAnnotation:[self.mapView.annotations objectAtIndex:counter]]) 
            {
                hitAnnotation = true;
            }
            counter++;
        }
        if (hitAnnotation) 
        {
            return NO;
        }

    }
    return YES; 
}

This works fine. My only problem are the callout bubbles of the pins and the double tap. Normally the double tap is used for zooming in. This still works but in addition to this, i also get a new pin. Is there any way to avoid this?

The other problem occurs with the callout bubble of a pin. I can open the bubble by tapping on the pin without setting a new pin at this place (see code above) but when i want to close the bubble by tapping on it, another pin is set. My problem is, that i cannot check with touch.view , if the user tapped on a callout bubble, because it is not a regular UIView as far as i know. Any ideas or workarounds for this problem?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:19:06+00:00Added an answer on May 25, 2026 at 1:19 am

    I had the same problem as your first problem: distinguishing double taps from single taps in an MKMapView. What I did was the following:

    [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];
    

    and then implemented the following delegate method:

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
    {
        return YES;
    }
    

    Using requireGestureRecognizerToFail: allows the app to distinguish single taps from double taps and implementing gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: ensures that double taps are still forwarded to the MKMapView so that it continues zooming normally. Note that doubleTapper doesn’t actually do anything (in my case, except log debug messages). It’s simply a dummy UIGestureRecognizer that’s used to help separate single taps from double taps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement my own provider for xml site map files. Because
I'm trying to implement an odata consumer, specifically right now related to doing batch
I am trying to implement my own map overlay for osmdroid (but I assume
I'm trying to implement my own List system in Java. the List class file
I'm trying to implement my own GenericIdentity implementation but keep receiving the following error
I am trying to implement my own authentication method for AuthKit and am trying
I'm trying to implement my own version of the 'cd' command that presents the
For all those ligthning fast shop users. I'm trying to implement my own first
Im trying to implement my own Huffman Coding algorithm and the priority queue for
I am trying to implement my own memory allocation code which is simple yet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.