开发者

MKAnnotationView do not anything

开发者 https://www.devze.com 2023-04-09 13:26 出处:网络
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
- (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

精彩评论

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

关注公众号