MKAnnotationView什么都没有

时间:2011-09-29 13:11:35

标签: objective-c ios mkmapview android-mapview mkannotationview

- (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;   
}

此代码无效。我正在添加JSON的引脚。我看到红色的针脚,但我看不到nslog(我正在工作)。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您需要在viewDidLoad或nib中或在创建它的任何位置设置mapView的委托。

相关问题