De manière Wich ce que je pourrais appeler la fonction qui ouvre automatiquement mon annotation (avec le titre, sous-titre, etc.), plutôt que de toucher sur l'annotation sur le MapView?
annotation automatique "canShowCallOut" IPHONE
voix
4
2 réponses
voix 4
4
Mettre en œuvre MKMapViewDelegatedélégué;
Mettre en œuvre - (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_;; par exemple comme ceci:
- (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;
}
Afficher la broche après la carte a terminé le chargement:
- (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];
}
Ce code a une annotation appelée propriété qui met en œuvre MKAnnotation. , Il anime également la chute de la broche aussi, mais il devrait être assez auto-expliquer.
HTH.
voix 3
3
Alfons répondu à la question, mais si vous cherchez quoi exactement ouvre automatiquement la légende, il est cette partie:
[mapView selectAnnotation:annotation animated:YES];













