You could set a button as the callout accessory view ,in the viewForAnnotation
method:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString *AnnotationIdentifier = @"Annotation";
if ([annotation isKindOfClass:MKUserLocation.class]) {
return nil;
}
MKPinAnnotationView* pinAnnotationView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
if (!pinAnnotationView)
{
pinAnnotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] ;
pinAnnotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinAnnotationView.canShowCallout = YES;
}
return pinAnnotationView;
}
then you can use the mapView:annotationView:calloutAccessoryControlTapped
delegate method to respond when users tap a callout view’s control and, in this case, redirect to another view controller:
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
InfoController *infoController = [[InfoController alloc] initWithNibName:@"InfoController" bundle:[NSBundle mainBundle]];
/*
here you can pass the necessary information to your InfoController
*/
[self.navigationController pushViewController:infoController animated:YES];
[infoController release];
}
In this example I take usage of a UINavigationController
to manage navigation through my view controllers.