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

  • SEARCH
  • Home
  • 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 8925019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:35:03+00:00 2026-06-15T07:35:03+00:00

I m working on an app using MKMapView there’s some annotation and when u

  • 0

I m working on an app using MKMapView

there’s some annotation and when u click on the annotation image , details are shown

for that i ve build my custom @interface Annotation : NSObject and added a boolean value “bClicked”

now I want the user to be able to click on a detail button inside the detailview but the code i ve made is not working :

#pragma mark - MKMapViewDelegate

 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
    MKAnnotationView *annotationView = nil;


    int index = 0;

    BOOL bFound = FALSE;

    for (int i=0;i<[shopAnnotations count];i++)
    {
        if (annotation == [shopAnnotations objectAtIndex:i])
        {
            index = i;
            bFound = TRUE;
            break;
        }
    }

    if (bFound==FALSE)
    {
        //ADLog(@"bFound FALSE annotation %p",annotation);
        return annotationView; // <-- nil
    }


    Annotation *shopAnnotation = [shopAnnotations objectAtIndex:index];

    annotationView = [_mapView dequeueReusableAnnotationViewWithIdentifier:shopAnnotation.identifier];

    if (!annotationView)
        annotationView = [[[MKAnnotationView alloc] initWithAnnotation:shopAnnotation reuseIdentifier:shopAnnotation.identifier] autorelease];

    for (UIView*view in annotationView.subviews)
    {
        [view removeFromSuperview];
    }

    annotationView.image = shopAnnotation.Image;
    annotationView.alpha = 1.0f;
    annotationView.enabled = YES;
    annotationView.canShowCallout = YES;

    annotationView.userInteractionEnabled = YES;

    if (shopAnnotation.bClicked==TRUE)
    {

        UIView *detailView = [[UIView alloc ] initWithFrame:CGRectMake(0, -50, 290, 56)];
        detailView.userInteractionEnabled = YES;
        detailView.superview = annotationView;
        [detailView release];

        UIImageView *bg = [[UIImageView alloc ] initWithImage:[UIImage imageNamed:@"bulle_carte.png"]];

        [bg setFrame:CGRectMake(0, 0, 290, 56)];
        bg.superview = detailView;

        [bg release];

        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

        [button setFrame:CGRectMake(250, 3, 35, 35)];

        [button setImage:[UIImage imageNamed:@"fleche_bleue_d.png"] forState:UIControlStateNormal];
        button.tag = [shopAnnotation.identifier intValue];
        [button addTarget:self action:@selector(btnDetailPressed:) forControlEvents:UIControlEventTouchUpInside];

        button.superview = detailView;

        button.userInteractionEnabled = YES;

        [annotationView setRightCalloutAccessoryView:detailView];

    }


return annotationView;
}

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view    calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"calloutAccessoryControlTapped");
}

-(void)btnDetailPressed:(id)sender
{
NSLog(@"btnDetailPressed");
}

when I click on the button or inside the DetailView, btnDetailPressed or calloutAccessoryControlTapped are not called/triggered.

Any suggestions?

  • 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-06-15T07:35:04+00:00Added an answer on June 15, 2026 at 7:35 am

    Use the MKMapViewDelegate‘s method mapView:didSelectAnnotationView::

    - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
    {
        if ([annotation isKindOfClass:[YOUR_CUSTOM_CLASS class]]) {
            //customize it
        }
    }
    
    - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
    {
        if ([view isKindOfClass:[YOUR_CUSTOM_CLASS class]]) {
            //do something
        }
    }
    

    Apple’s doc

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

Sidebar

Related Questions

I'm currently working on an app using MVVM that needs to have some data
I'm working on an app using Bluetooth discovery pretty heavily (some detail here ).
I am working on a app where I have to make Map using MKMapView
I have a working android app using TextView, some formatting (line breaks, rows of
i'm trying to get multi tenancy working in my app - using nhibernate integration
Im working on an iphone web app using JQTouch , im just wondering what
So I'm working on a mobile web app using jQuery Mobile, and I need
I am working on a dynamic web app using Eclipse with Tomcat 7 and
I am working on a load generator app using akka actors. The app worked
I am currently working on a web app using Wicket and started using jQuery

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.