In wich Art und Weise konnte ich rufen Sie die Funktion, die automatisch meine Anmerkung öffnen (mit Titel, Untertitel, usw.), anstatt sich auf die Anmerkung auf der mapview zu berühren?
Automatisch „canShowCallOut“ Anmerkung IPHONE
stimmen
4
2 antworten
stimmen 4
4
Implementieren Sie MKMapViewDelegatedelegieren;
implementieren - (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_;; zum Beispiel wie folgt aus :
- (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;
}
Zeigen Sie den Stift nach der Karte geladen wird:
- (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];
}
Dieser Code hat eine Eigenschaft namens Anmerkung , die implementiert MKAnnotation. Außerdem ist es belebt die Stecknadel fallen auch, aber es sollte ziemlich selbsterklärend sein.
HTH.
stimmen 3
3
Alfons beantwortet die Frage, aber wenn Sie auf der Suche nach was genau automatisch öffnet die callout, es ist dieser Teil:
[mapView selectAnnotation:annotation animated:YES];













