I am trying to use some delegate methods in MKMapViewDelegate. Specifically, I want to give the pop out an accessory arrow so that when user touches it, it launches native map application (for full blown mapping functions.)
I think I understand correctly that once the VC is set up as a delegate of itself then the protocol methods get called automatically. In that case do delegate methods get called automatically or do you have to do something else?
Here is method to launch map.
-(void) geoCodeAndMapIt {
NSString* location = @"156 University Ave, Palo Alto, CA 94301";
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:location
completionHandler:^(NSArray* placemarks, NSError* error){
if (placemarks && placemarks.count > 0) {
CLPlacemark *topResult = [placemarks objectAtIndex:0];
MKPlacemark *placemark = [[MKPlacemark alloc]
initWithPlacemark:topResult];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(placemark.coordinate, 5000, 5000);//5000 is meters
region.span.longitudeDelta /= 8.0;
region.span.latitudeDelta /= 8.0;
[self.mapView setRegion:region animated:YES];
[self.mapView addAnnotation:placemark];
}
Here is method that should add accessory arrow to callout but is not firing:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"loc"];
annotationView.canShowCallout = YES;
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
return annotationView;
}
How do I get this method to fire so I get accessory arrow? Thanks for any suggestions.