This is follower question of Move image from left to right I have used this code for moving image from left to right, and write some code in touchBegan to stop this animation when touch on this image .But its not working during animation. when the animation end then if touch on image then this touchBegan is call.
My requirement is, during ani开发者_运维问答mation if image is touched then touchBegan should be execute.
UIImage *image = [UIImage imageNamed:@"PG05(REV).jpg"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(-1024, 0, 1024, 768);
[self.view addSubview:imageView];
[imageView release]; //Your imageView is now retained by self.view
//Animation
[UIView animateWithDuration:10.0
animations:^(void) {
imageView.frame = CGRectMake(0, 0, 1024, 768);
}];
Please help me out.
You probably need this method -animateWithDuration:delay:options:animations:completion:. Replace current method with
[UIView animateWithDuration:10.0
delay:0.0
options: UIViewAnimationOptionAllowUserInteraction
animations:^{
imageView.frame = CGRectMake(0, 0, 1024, 768);
}
completion:nil];
This should enable touches during the animation.
精彩评论