Recientemente me he encontrado con this website y he estado tratando de agregar a mi llamada ver un botón (desde una imagen).¿Agregar un botón de vista de accesorio a la anotación de llamada de MKMapView?
El código en el ejemplo de sitios web funciona bien, pero cuando traté de agregar el mismo código a mi proyecto, no obtengo los mismos resultados.
Obviamente, es algo que he echado de menos pero parece que no puedo solucionarlo.
Aquí está mi código para anotar:
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorGreen;
UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeCustom];
advertButton.frame = CGRectMake(0, 0, 23, 23);
advertButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
advertButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[advertButton setImage:[UIImage imageNamed:@"button_right.png"] forState:UIControlStateNormal];
[advertButton addTarget:self action:@selector(showLinks:) forControlEvents:UIControlEventTouchUpInside];
annView.rightCalloutAccessoryView = advertButton;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
return annView;
}
Cualquier ayuda sería muy apreciada! :)
Por desgracia, El enlace que proporcionó está muerto –