pasador de anotación personalizado
Frecuentes
Visto 701 veces
0
tengo clase
@interface MyLocation : NSObject <MKAnnotation>
@property (copy) NSString *name;
@property (copy) NSString *address;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, strong) UIImage *banner;
@property (nonatomic, strong) NSString *descr;
Cuando agrego la ubicación en el mapa, quiero ese método - (MKAnnotationView*) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
mostrar banner .... ¿cómo puedo hacer esto?
- (MKAnnotationView*) mapView:
(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
static NSString *identifier = @"MyLocation";
if ([annotation isKindOfClass:[MyLocation class]]) {
MKPinAnnotationView *annotationView = (MKPinAnnotationView*)
[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.image = [UIImage imageNamed:@"Image2.jpg"];
return annotationView;
}
return nil;
}
este método cambia todos los pines de anotación, pero necesito imágenes diferentes para cada anotación. ¡Gracias por la ayuda!
2 Respuestas
0
Debe usar MKAnnotationView para pines personalizados, ya que MKPinAnnotationView siempre muestra los pines "predeterminados".
Respondido el 26 de junio de 12 a las 12:06
0
Custom CLASS MKAnnotationView, y U puede cambiar los pines, vea el código de muestra de Apple:leyendas del mapa
Respondido 22 Oct 13, 12:10
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas ios mkmapview mkannotationview or haz tu propia pregunta.
Tenga en cuenta que respuestas de solo enlace se desalientan, las respuestas SO deben ser el punto final de la búsqueda de una solución (frente a otra escala más de referencias, que tienden a volverse obsoletas con el tiempo). Considere agregar una sinopsis independiente aquí, manteniendo el enlace como referencia. - kleopatra