¿Agregar un botón de vista de accesorios a la anotación de llamada de MKMapView?
Me he encontrado recientementeeste sitio web y he estado intentando agregar a mi llamada para ver un botón (desde una imagen).
El código del ejemplo de sitios web funciona bien, pero cuando intenté agregar el mismo código a mi proyecto no obtengo los mismos resultados.
Obviamente hay algo que me he perdido, ¡pero parece que no puedo resolver esto!
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 apreciada! :)