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 7655187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:26:56+00:00 2026-05-31T12:26:56+00:00

Here is what I want – user taps on the map, my code gets

  • 0

Here is what I want – user taps on the map, my code gets executed and then system code is executed (if user clicked on annotation callout is presented etc…).

I added simple tap recognizer to map view:

UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mapViewTapped:)];
[self.mapView addGestureRecognizer:tapGestureRecognizer];
[tapGestureRecognizer release];

Inside mapViewTapped my code gets executed. Now I want to notify system code of tap (for example to show callout). How do I do that? How to pass event that I intercepted?

  • 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-31T12:26:57+00:00Added an answer on May 31, 2026 at 12:26 pm

    One way is to implement the UIGestureRecognizerDelegate method gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: and return YES in it:

    //add <UIGestureRecognizerDelegate> to .h to avoid compiler warning
    
    //add this where you create tapGestureRecognizer...
    tapGestureRecognizer.delegate = self;
    
    -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer 
        shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
    {
        return YES;
    }
    

    Now your mapViewTapped: will get called and then the map view’s recognizer will call its method. If the tap was on an annotation view, the map view will show its callout (and the didSelectAnnotationView delegate method will get called if you’ve implemented it).

    Another way, if you need more control, then instead of doing the above, in your mapViewTapped: you can check if the tap was on an annotation view and then manually select the annotation which will then show its callout (and call the didSelectAnnotationView delegate method):

    -(void)mapViewTapped:(UITapGestureRecognizer *)tgr
    {
        CGPoint p = [tgr locationInView:mapView];
    
        UIView *v = [mapView hitTest:p withEvent:nil];
    
        id<MKAnnotation> ann = nil;
    
        if ([v isKindOfClass:[MKAnnotationView class]])
        {
            //annotation view was tapped, select it...
            ann = ((MKAnnotationView *)v).annotation;
            [mapView selectAnnotation:ann animated:YES];
        }
        else
        {
            //annotation view was not tapped, deselect if some ann is selected...
            if (mapView.selectedAnnotations.count != 0)
            {
                ann = [mapView.selectedAnnotations objectAtIndex:0];
                [mapView deselectAnnotation:ann animated:YES];
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here I want to know the status of the last executed call of system()
Here's what I want to do: I want to allow the user to give
here i want to solve stack overflow issue in this code. here in this
As discussed in similar questions here and here I want to protect my code
There is a post to set system-wide global hotkey in C# here I want
Here i want to upload the pictures to the website. i listed the code
This is my ajax image uploade code.Here i want also check size of the
I'm not entirely sure if I can do what I want here, but I
I've managed to find the Regex to get almost the result I want here
I know, I am propably way out of line here :-) I want to

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.