这是我的代码:
- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if ([annotation class] == MKUserLocation.class) {
return nil;
}
static NSString *identifier=@"an";
MKAnnotationView *pinView = nil;
pinView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (pinView == nil)
{
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
pinView.canShowCallout = YES;
NSLog(@"NEW ONE CREATED");
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
似乎这不起作用,并且 pinView 始终为零,因为我可以看到创建的每个 pin 的 nslog。