我的注释代码是:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
static NSString *identifier = @"RoutePinAnnotation";
if ([annotation isKindOfClass:[UICRouteAnnotation class]]&&[(UICRouteAnnotation *)annotation annotationType] != UICRouteAnnotationTypeWayPoint)
{
MKPinAnnotationView *pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if(!pinAnnotation) {
pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier] autorelease];
}
if ([(UICRouteAnnotation *)annotation annotationType] == UICRouteAnnotationTypeStart) {
pinAnnotation.pinColor = MKPinAnnotationColorGreen;
} else if ([(UICRouteAnnotation *)annotation annotationType] == UICRouteAnnotationTypeEnd) {
pinAnnotation.pinColor = MKPinAnnotationColorRed;
}
pinAnnotation.animatesDrop = YES;
pinAnnotation.enabled = YES;
pinAnnotation.canShowCallout = YES;
return pinAnnotation;
}
}
应用程序首先运行良好,但是当我们缩放地图时它会崩溃。
由于未捕获的异常 NSInvalidArgumentException 而终止应用,原因:-[MKAnnotationView setPinColor:]
请帮我!!感谢