I have a draggable class that inherits UIImageView. The drag works fine when the view is not animating. But when animating it won't respond to touches. Once the animation is completed the touch works again. But I need it to pause the animation on touches and resume when touch ends. I spent the whole day researching it but couldn't figure out the reason.
Here is my animation code.
[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];
}
See Question&Answers more detail:os