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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:28:50+00:00 2026-05-17T19:28:50+00:00

I have a mapview with a few pins on it. The pins are loading

  • 0

I have a mapview with a few pins on it. The pins are loading longitude and latitude from a plist. I’ve also added a detailview where you get more info about the pin that gets tapped. However my problem is that when I tap on a pin (discloseButton ofc) and get pushed to the detailview it’s always the last items data that loads (from the plist). It doesn’t matter which pin I tap.

For example:

item 1 – title: car

item 2 – title: ball

item 3 – title: book

item 4 – title: bicycle

So if I tap on pin nr 1 the title in the detailview is bicycle. If I tap on pin nr 2 the title in the detailview is bicycle and so on. Hope you get the point 🙂

(Sorry for the bad title couldn’t come up with a better one.)

Thanks!

Here’s some code if it helps:

RootViewController.m

- (void)viewDidLoad {
[super viewDidLoad];

    self.title = @"Map";

    map.delegate = self;

    cam = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] 
                                                     pathForResource:@"Cam" 
                                                     ofType:@"plist"]];

    double minLat = [[cam valueForKeyPath:@"@min.latitude"] doubleValue];
    double maxLat = [[cam valueForKeyPath:@"@max.latitude"] doubleValue];
    double minLon = [[cam valueForKeyPath:@"@min.longitude"] doubleValue];
    double maxLon = [[cam valueForKeyPath:@"@max.longitude"] doubleValue];

    MKCoordinateRegion region;
    region.center.latitude = (maxLat + minLat) / 2.0;
    region.center.longitude = (maxLon + minLon) / 2.0;
    region.span.latitudeDelta = (maxLat - minLat) * 1.05;
        region.span.longitudeDelta = (maxLon - minLon) * 1.05;
    map.region = region;

    for (NSDictionary *camDict in cam){
        annotationTest = [[MyAnnotation alloc] initWithDictionary:camDict];
        [map addAnnotation:annotationTest];
        [annotationTest release];
    }
}


// AnnotatioView
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{

     MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"];
    [annView setAnimatesDrop:YES];
    [annView setCanShowCallout:YES];
    [annView setSelected:YES];
    [annView setUserInteractionEnabled: YES];

    UIButton *discloseButton = [UIButton buttonWithType: UIButtonTypeDetailDisclosure];
    [discloseButton addTarget: self action: @selector(showMyView:) forControlEvents:    UIControlEventTouchUpInside];
    annView.rightCalloutAccessoryView = discloseButton;

    return annView;
}

//Push the detailView with some data
- (IBAction)showMyView:(id)sender {
    DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];

    detailViewController.title = annotationTest.title;
    detailViewController.tempAdress = annotationTest.subtitle;
    detailViewController.tempUrl = annotationTest.url;

    [self.navigationController pushViewController:detailViewController animated:YES];
    [detailViewController 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-05-17T19:28:50+00:00Added an answer on May 17, 2026 at 7:28 pm

    Yay, fixed it! Here’s was I did.

    - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
    
        MKPinAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"];
        [pin setAnimatesDrop:YES];
        [pin setCanShowCallout:YES];
        [pin setSelected:YES];
        [pin setUserInteractionEnabled: YES];
    
        pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    
        return pin;
    }
    
    - (void)mapView:(MKMapView *)mv annotationView:(MKAnnotationView *)pin calloutAccessoryControlTapped:(UIControl *)control { 
        DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
    
        detailViewController.title = pin.annotation.title;  
    
        [self.navigationController pushViewController:detailViewController animated:YES];
        [detailViewController release];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small app that from the home screen has a few buttons,
i have a mapView with pins on it, and the following code for CLLocation
I have a MKMapView (also a UIPopoverControllerDelegate) with Annotations. This MapView has, in the
I have a Mapview in my Titanium project. I can get the map to
I have a mapview where i update my currentlocation with CoreLocation, but I also
I have a MapView in my app and am drawing a few circle overlays
I have a MapView where Drawable markers are placed with a limit set to
I have a mapview with several annotations. Every annotation has a leftCalloutAccessoryView which is
I have a MapView that will contain alot of overlays. For this i've extended
I have a mapview, with the MyLocationOverlay, and other overlays. MyLocationOverlay is drawn under

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.