Estoy haciendo una aplicación donde tengo una vista de fondo y que tiene seis UIImageView
como subvistas. Tengo un UITapGestureRecognizer
para ver cuándo se toca uno de los UIImageView
s y el método handleTap a continuación es lo que llama el reconocedor de gestos. Sin embargo, cuando ejecuto esto, el hitTest:withEvent:
siempre devuelve la vista de fondo incluso cuando toco en una de las imageViews. ¿Tiene algo que ver con el evento cuando llamo a hitTest?hitTest: withEvent: Not Working
Gracias
- (void) handleTap: (UITapGestureRecognizer *) sender
{
if (sender.state == UIGestureRecognizerStateEnded)
{
CGPoint location = [sender locationInView: sender.view];
UIView * viewHit = [sender.view hitTest:location withEvent:NULL];
NSLog(@"%@", [viewHit class]);
if (viewHit == sender.view) {}
else if ([viewHit isKindOfClass:[UIImageView class]])
{
[self imageViewTapped: viewHit];
NSLog(@"ImageViewTapped!");
}
}
}
¡Muchas gracias! –