i have 5 animating image in a image view and will like to allow user to tap on them base on the default ID and push it to another view. i tried to add in gesture tap but the
It is because that when animation is applying, the modification for any value of the sprite(UIImageView in your case) by animation is not applied to the sprite original, it is applied to its .layer.presentationLayer, the real one is still at its original place. In this case, you can try this: Put your gesture on the whole screen, when response comes from event, you check the touch point, make a hitTest to the presentationLayer, if yes then do what you want.
I usually use below code to do that.
- ( BOOL ) areYouThere: ( CGPoint ) point {
return ( [ ( ( CALayer * )sprite.layer.presentationLayer ) hitTest: point ] != nil );
}
Get the touch point from a UITouch object when below method is invoked
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
Really late but I've been facing the same issue and I found what I think is a better solution:
Just use the UIViewAnimationOptionAllowUserInteraction option like that:
[UIView animateWithDuration:4.0
delay:0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
imageViewTop.alpha = 0.0;
imageViewBottom.alpha = 1.0;
}
completion:^(BOOL completed){
[self nextAnimation:stringsize.width];
}
];
I would add a transparent view on top of the image view and add a gesture recognizer to that.