Tengo una clase arrastrable que hereda UIImageView. El arrastre funciona bien cuando la vista no está animando. Pero al animarlo no responderá a los toques. Una vez que se completa la animación, el toque funciona nuevamente. Pero necesito pausar la animación en toques y reanudarla cuando termine el toque. Pasé todo el día investigando pero no pude descubrir el motivo.UIView touchesbegan no responde durante la animación
Aquí está mi código de animación.
[UIView animateWithDuration:5.0f
delay:0
options:(UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
animations:^{
self.center = CGPointMake(160,240);
self.transform = CGAffineTransformIdentity;
}
completion:nil
];
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
NSLog(@"touch");
CGPoint pt = [[touches anyObject] locationInView:self];
startLocation = pt;
[self.layer removeAllAnimations];
[[self superview] bringSubviewToFront:self];
}
Brilliant. ¡Gracias! – bzlm
btw He tenido problemas con esto incluso cuando la posición no está animando, pero otra propiedad ('frame' en mi caso) es ... todavía obtienes toques que simplemente se tragan, aunque la vista sea' hitTest' y Los métodos 'pointInside' se llaman y regresan correctamente. Además, solo estoy haciendo 'if ([view pointInside: point withEvent: event])' - no hay necesidad de 10 puntos de slop – AlexChaffee