declare your class MKMapViewDelegate. Then add
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"String"];
if(!annotationView) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"String"];
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
return annotationView;
}
Then you add:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
ViewController *detailViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
}
... ViewController could be anything you defined (I use nib files ...)
source
share