"CanShowCallOut" IPHONE automática de anotación

votos
4

En forma wich podría yo llamar a la función que se abren automáticamente mi anotación (con título, subtítulo, etc.), en lugar de tocar en la anotación en el MapView?

Publicado el 20/03/2010 a las 17:36
fuente por usuario
En otros idiomas...                            


2 respuestas

votos
4

Implementar MKMapViewDelegatedelegado;

implementar - (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_;; por ejemplo como esta:

    - (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;
}

Mostrar el pin después de que el mapa ha terminado de cargar:

- (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];
}

Este código tiene una propiedad llamada anotación que implementa MKAnnotation. Además, se anima a la caída de un alfiler también, pero debe ser bastante autoexplicativo.

HTH.

Respondida el 21/03/2010 a las 21:47
fuente por usuario

votos
3

Alfons responde a la pregunta, pero si usted está buscando exactamente lo que abre automáticamente la llamada, es esta parte:

[mapView selectAnnotation:annotation animated:YES]; 
Respondida el 10/01/2012 a las 05:09
fuente por usuario

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