MKAnnotationView do not anything
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
NSLog(@"I'm Working");
static NSString *identifier = @"MyLocation";
if ([annotation isKindOfClass:[userPins class]]) {
userPins *location = (userPins *) annotation;
MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
if ([location.name compare:@"LARCENY"] == NSOrderedSame) {
annotationView.pinColor = MKPinAnnotationColorGreen;
}
return annotationView;
}
return nil;
}
This code not working. I'm adding pins from JSON. I see red pins but I can't see nslog(I开发者_C百科'm working). Any ideas?
You need to set the mapView's delegate in viewDidLoad or in the nib or wherever you are creating it.
精彩评论