2011-08-19 80 views

回答

4

覆盖这一点,并MKMapViewDelegate的委托来实现覆盖的方法。

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation; 

创建注释,

MKAnnotationView *annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];// get a dequeued view for the annotation like a tableview 

if (annotationView == nil) 
    { 
     annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease]; 
    } 
    annotationView.annotation = annotation; 
    annotationView.canShowCallout = YES; // show the grey popup with location etc 
    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    ///[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside]; 
    annotationView.rightCalloutAccessoryView = rightButton; 

    annoationView.image = [UIImage imageNamed:@"random.png"]; 

自定义图像进行

2

是的,在viewForAnnotation委托回调可以提供力所能及的观看你喜欢的。

1

对于自定义标注图像,设置图像属性,因为这样。

UIImage *annImage = [UIImage imageNamed:@"AnnotationIcon.png"]; 
annView.image = annImage; 

请注意,MKPinAnnotationView animateDrop属性不会对自定义图像工作。有一种方法可以复制该动画。见How do I animate MKAnnotationView drop?