2011-08-19 81 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?