Una forma es poner en práctica el método UIGestureRecognizerDelegate
gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
y volver YES
en ella:
//add <UIGestureRecognizerDelegate> to .h to avoid compiler warning
//add this where you create tapGestureRecognizer...
tapGestureRecognizer.delegate = self;
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
Ahora su mapViewTapped:
se llamará y luego reconocedor de la vista del mapa será llamar a su método. Si el tap estaba en una vista de anotación, la vista del mapa mostrará su llamada (y se llamará al método de delegado didSelectAnnotationView
si lo ha implementado).
otro modo, si se necesita más control, entonces en vez de hacer lo anterior, en su mapViewTapped:
se puede comprobar si el grifo estaba en una vista de anotación y luego seleccionar manualmente la anotación que luego mostrar su llamada (y llamar al método didSelectAnnotationView
delegado):
-(void)mapViewTapped:(UITapGestureRecognizer *)tgr
{
CGPoint p = [tgr locationInView:mapView];
UIView *v = [mapView hitTest:p withEvent:nil];
id<MKAnnotation> ann = nil;
if ([v isKindOfClass:[MKAnnotationView class]])
{
//annotation view was tapped, select it...
ann = ((MKAnnotationView *)v).annotation;
[mapView selectAnnotation:ann animated:YES];
}
else
{
//annotation view was not tapped, deselect if some ann is selected...
if (mapView.selectedAnnotations.count != 0)
{
ann = [mapView.selectedAnnotations objectAtIndex:0];
[mapView deselectAnnotation:ann animated:YES];
}
}
}
gracias, su explicación no sólo era útil, pero muy detalladas – MegaManX
Muchas gracias, su segunda sugerencia era exactamente lo que buscaba! – MrDB
Una gran sugerencia, era lo que estaba buscando –