Three steps.
1) In your header file (.h) or your implementation file's (.m) class extension conform to MKMapViewDelegate
:
@interface ViewController : UIViewController <MKMapViewDelegate> { ... }
2) Set your view controller as the delegate of MKMapViewDelegate
to receive delegate callbacks. Commonly done in viewDidLoad
:
- (void)viewDidLoad
{
[super viewDidLoad];
self.mapView.delegate = self;
}
3) Implement the following delegate function to show the disclosure button:
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pinLocation"];
newAnnotation.canShowCallout = YES;
newAnnotation.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
return newAnnotation;
}
the following function will assist in determining what action (in your case, presenting a view) is taken upon touching the disclosure button.
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
//launch a new view upon touching the disclosure indicator
TestVCViewController *tvc = [[TestVCViewController alloc] initWithNibName:@"TestVCViewController" bundle:nil];
[self presentViewController:tvc animated:YES completion:nil];
}