0

I have a map that has multiple annotations that are plotted on the map sourced from JSON data that are broken up by category within a UITableViewController that contains information like their latitude and longitude as well as other information like: address, phone number and so on...

I know how to add a detail disclosure button to the annotation view for each one, but how to do I get that information into a detail viewController?

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
    if([annotation isKindOfClass:[MKUserLocation class]]) {

        return nil;
    }
    MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annoPin"];
    MKAnnotationView *view = [self.mapView dequeueReusableAnnotationViewWithIdentifier:@"annoView"];
    if(!view) {
        view = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annoView"];
    }



    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton addTarget:nil action:@selector(showDetails :) forControlEvents:UIControlEventTouchUpInside];
    pinView.animatesDrop = YES;
    view.rightCalloutAccessoryView = rightButton;
    view.image = [UIImage imageNamed:@"check.png"];
    view.enabled = YES;
    view.canShowCallout = YES;
    return view;
}

As you can see I've created a button, but how do I get the JSON info for each category over to a detail ViewController for each category inside of the UITableViewController?

Lalalalalala
  • 167
  • 1
  • 1
  • 10

1 Answers1

0

When you create the annotation that you add to your mapview you need to give it all the information that will eventually get to the detail view controller, or at least a reference to the data that you can get later. Then in mapView:annotationView:calloutAccessoryControlTapped:, which gets called on the map delegate when a disclosure button is tapped, you get the annotationview's annotation and get the data from there.

Craig
  • 8,093
  • 8
  • 42
  • 74