开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜