i use MapKit to locate user and i want to personnalize the text which appear when the user click on the annotation, the default text is current location
here is my code :
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentLoc"];
// annotation color
[annView setPinColor:MKPinAnnotationColorGreen];
//annotation Animation
[annView setAnimatesDrop:YES];
[a开发者_开发知识库nnView setCanShowCallout:YES];
return annView;
}
You want to use MKAnnotationView rather than MKPinAnnotationView. MKAnnotationView has a property called annotation which has a property called title, so:
annview.annotation.title = @"title";
I haven't tested doing it this way exactly, the usual way to do it is to make a custom class that implements the MKAnnotation protocol and then add instances of that class to the map.
精彩评论