0

actually, i have retrieved a lot of informations about service stations from web-service, they are here, i displayed for each Station a pin annotation to show it on the Map with a UIButtonTypeDetailDisclosure, now i want to store for each pin some additional informations like :

float lng = [[stationEnCours objectForKey:@"ssiphone_longitude"] floatValue];//that's how i retrieve it from web-service
float lat = [[stationEnCours objectForKey:@"ssiphone_latitude"] floatValue];//that's how i retrieve it from web-service

for my purpose, i use this well known method of the delegate :

 -(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
    {
        NSLog(@"calloutAccessoryControlTapped");
//how to do to store additional informations

    }

but i am some kind blocked, how can i store additional informations related to each pin, help please, any suggestions, sample code, tutorials will be appreciated :))))) thx in advance

Luca
  • 20,399
  • 18
  • 49
  • 70
  • 2
    I'm not sure what the difficulty is. Don't you have a custom class that implements the MKAnnotation protocol? In calloutAccessoryControlTapped, you can access the annotation using view.annotation. –  May 10 '11 at 13:34
  • Hi, i have a class named MyLocation which implement the MKAnnotation protocol, should i declare in `MyLocation.h` file all properties that i would display in the detail view, if so, how can i assign and get values, in other words, how can i read it in the `calloutAccessoryControlTapped` method ? thx in advance :) – Luca May 10 '11 at 13:52

1 Answers1

2

Yes, declare all your properties in MyLocation.h (the class that implements MKAnnotation). When creating annotations and before calling addAnnotation, set the properties.

In calloutAccessoryControlTapped, get the properties like this (example uses properties in MyLocation defined in your previous question):

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
    MyLocation *myLoc = (MyLocation *)view.annotation;
    NSLog(@"calloutAccessoryControlTapped: enseigneDeLaStation = %@, distanceVersLaStation=%@", myLoc.enseigneDeLaStation, myLoc.distanceVersLaStation);
}
  • Hi Anna, please, in this method (`calloutAccessoryControlTapped`), i am trying to move the user to another view where he will be able to see the details, so i do this `[self presentModalViewController:detailStation animated:YES];`however, i see a white screen although `detailStation` is declared and connected in IB, can you help me there ? thx in advance :) – Luca May 10 '11 at 18:37
  • You should ask that as a new question and include the complete code in calloutAccessoryControlTapped, show how and where detailStation is declared in code and how exactly it is connected in IB, etc. –  May 10 '11 at 18:55
  • Hi, this is my new post : http://stackoverflow.com/questions/5954920/white-screen-when-i-click-on-uibuttontypedetaildisclosure – Luca May 10 '11 at 18:57