2011-03-11 65 views

回答

1

在viewForAnnotation方法中,创建一个MKAnnotationView(不是MKPinAnnotationView)并设置其图像属性。

1

此外,您可以继承mkannotationview以添加更多功能。

0

您需要将下面的代码添加到您的viewForAnnotation消息:

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation 
{ 
    // ... get the annotation delegate and allocate the MKAnnotationView (annView) 
    if ([annotationDelegate.type localizedCaseInsensitiveCompare:@"needs_your_image"] == NSOrderedSame) 
    { 
     UIImage * image = [UIImage imageNamed:@"your_image_here.png"]; 
     UIImageView *imageView = [[[UIImageView alloc] initWithImage:image] autorelease]; 
     [annView addSubview:imageView]; 
    } 
    // ...