annotation automatique "canShowCallOut" IPHONE

voix
4

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?

Créé 20/03/2010 à 17:36
source utilisateur
Dans d'autres langues...                            


2 réponses

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

Créé 21/03/2010 à 21:47
source utilisateur

voix
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]; 
Créé 10/01/2012 à 05:09
source utilisateur

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