Automatic annotation "canShowCallOut" IPHONE

In what order can I call a function that automatically opens my annotation (with title, subtitles, etc.), and not touch the annotation on the map?

+4
source share
2 answers

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_ { // if done loading, show the call out [self performSelector:@selector(dropPin) withObject:nil afterDelay:0.3]; } 

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.

+4
source

Alphonse answered the question, but if you are looking for what exactly automatically opens the leader, then this part:

 [mapView selectAnnotation:annotation animated:YES]; 
+3
source

Source: https://habr.com/ru/post/1304655/


All Articles