IOS/Objective C/MKMapViewDelegate: 获取annotationView显示辅助箭头

IOS/Objective C/MKMapViewDelegate: Get annotationView to show accessory arrow

我正在尝试在 MKMapViewDelegate 中使用一些委托方法。具体来说,我想给弹出一个附件箭头,这样当用户触摸它时,它会启动本地地图应用程序(用于完整的地图绘制功能。)

我想我的理解是正确的,一旦 VC 被设置为它自己的委托,协议方法就会被自动调用。在那种情况下,委托方法是自动调用还是您必须执行其他操作?

这是启动地图的方法。

-(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];
}

这是应该向标注添加附件箭头但未触发的方法:

- (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;
}

如何触发此方法以便获得附件箭头?感谢您的任何建议。

当您在注释视图中单击按钮时,为什么不使用此方法此方法已触发,您可以在那里执行自定义操作。

 - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
        //Do whatever you want to do here.

        PropertyLocation *location = (PropertyLocation*)view.annotation;

        for(PropertyDTO *property in self.items)
        {
            if(property.location == location)
            {
                PropertyDetailVC *detailVC = [PropertyDetailVC propertyDetailVCWithNodeID:property.nodeID];

                [self.navigationController pushViewController:detailVC animated:YES];
            }
        }

    }