Implement delegate MKMapViewDelegate ;
Embed - (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_; ; eg:
- (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_ { MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"YourPinId"]; if (pin == nil) { pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation_ reuseIdentifier: @"YourPinId"] autorelease]; } else { pin.annotation = annotation_; } pin.pinColor = MKPinAnnotationColorRed; [pin setCanShowCallout:YES]; pin.animatesDrop = YES; return pin; }
Show the output after the map download is complete:
- (void) dropPin { [mapView addAnnotation:self.annotation]; [mapView selectAnnotation:self.annotation animated:YES]; } - (void) mapViewDidFinishLoadingMap: (MKMapView *) mapView_ {
This code has a property called annotation that implements MKAnnotation . In addition, it animates the fall of the pin, but it should be quite explanatory.
NTN.
source share