2011-09-29 48 views
0
- (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(我正在工作)。有任何想法吗?MKAnnotationView做没有什么

+0

请更好的格式您的文章。你有没有试过设置一个断点? –

+0

你加在你的.h文件MKMapViewDelegate协议参考? – tilo

回答

1

您需要设置的MapView的代表在viewDidLoad中或笔尖或任何你正在创建它。