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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:15:36+00:00 2026-06-08T11:15:36+00:00

I have a map view with pins that when the user selects a pin

  • 0

I have a map view with pins that when the user selects a pin it goes to a detail screen for that pin. I also have a table view that when the user selects an item it goes to the same type detail view.

I am adding the multiple pins in mapview through array. I have added button to the accessory view,

Here’s the problem …

when I tap the button pin selection takes him to the detail view for a different pin. But in the table view it still works fine..anyone pls help me with this…?

-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 
{
    MKPinAnnotationView *newAnnotation = nil;
    if([annotation.title isEqualToString:@"You are here."])
    {
        newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"greenpin"];
        newAnnotation.pinColor = MKPinAnnotationColorGreen;
    }
    else
    {      
        newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"redpin"];
        newAnnotation.pinColor = MKPinAnnotationColorRed;
        UIButton *pinButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinButton.tag = indexvar;
        [newAnnotation addSubview:pinButton];
        newAnnotation.canShowCallout = YES;    
        newAnnotation.rightCalloutAccessoryView = pinButton;
        newAnnotation.calloutOffset = CGPointMake(-5, 5);
        indexvar++;
        return newAnnotation;
        [pinButton release];
    }
    newAnnotation.animatesDrop = YES;
    newAnnotation.canShowCallout = YES;
    return newAnnotation;
}

- (void)mapView:(MKMapView *)wikiMapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 
{
    NSInteger selectedIndex = ((UIButton *)control).tag;
    NSLog(@"Property Index : %d ",selectedIndex);
    DetailView = [[PropertyDetails alloc] initWithNibName:@"PropertyDetails" bundle:nil];
    DetailView.propertyReference = [PropertyReferenceArr objectAtIndex:selectedIndex];
    DetailView.propertyTitle = [propertyTitlesArr objectAtIndex:selectedIndex];
    DetailView.propertyPrice = [propertyPriceArr objectAtIndex:selectedIndex];
    DetailView.propertyBedrooms = [propertyBedroomsArr objectAtIndex:selectedIndex];
    DetailView.propertyLatitude = [propertyLatitudesArr objectAtIndex:selectedIndex];
    DetailView.propertyLongitude = [propertyLongitudesArr objectAtIndex:selectedIndex];
    DetailView.propertyDefaultImage = [PropertyImageArr objectAtIndex:selectedIndex];
    DetailView.propertyStatusId = [PropertyStatusArr objectAtIndex:selectedIndex];
    [self.navigationController pushViewController:DetailView animated:YES];         
    [DetailView release]; 
}
  • 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-08T11:15:38+00:00Added an answer on June 8, 2026 at 11:15 am
    -(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
    {    
        myAnnotation *annView = view.annotation; // myAnnotation is my custom class for annotations
        // now in annView you have the exact annotation whose accessorybutton is clicked now you can do whatever you want with it.
        NSLog(@"title = %@",annView.title);
    }
    

    Rather then setting the button tag you can use the title or subtitle of the annotation for futher comparision or whatever you want

    In your code you are using

    [newAnnotation addSubview:pinButton]; // i think this is wrong you should only add it to accessory view
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can i use fragments and map view in the same activity. I have seen
i have a scroll view which represents a map, it has pins on it,
In my Map application I have segment controller on main screen and using that
I have a map view with pins annotations into it. I need to pass
I have a map view activity that shows a few OverlayItems . In the
I have a map view with thousand of items that i want to load
I have implemented an app that shows a map with a lot of pins
I have some pins that the user can add. In the callout there is
I currently have a map view that is populated with several objects following the
I have an app that has a mapview, and it shows 20 pins (from

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.