2011-09-29 73 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中或筆尖或任何你正在創建它。