Automatisch „canShowCallOut“ Anmerkung IPHONE

stimmen
4

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?

Veröffentlicht am 20/03/2010 um 17:36
quelle vom benutzer
In anderen Sprachen...                            


2 antworten

stimmen
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.

Beantwortet am 21/03/2010 um 21:47
quelle vom benutzer

stimmen
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]; 
Beantwortet am 10/01/2012 um 05:09
quelle vom benutzer

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more