我有一个带有视图控制器的地图作为它的委托,我调用下面的方法向地图添加一些自定义引脚并获取到它们的路线。
我想将路线的距离添加到引脚,所以我需要计算路线,然后在返回引脚之前将距离添加到自定义引脚。
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
//setup custom pin view and directions request
[directions calculateDirectionsWithCompletionHandler:
^(MKDirectionsResponse *response, NSError *error) {
if (error)
{
// error
} else {
// no error
}
}];
// add distance to custom pin view
// ONLY once directions calculated
return custom pin view;
}
任何想法我将如何解决这个问题?