ios中的动画期间,imageview的手势不起作用
我正在实现一个imageView的动画。在这个动画中,我的气球图像是从下到上的,如果用户要触摸气球,我想将其隐藏。但是我的手势在动画过程中不起作用。有人能帮我吗。提前谢谢ios中的动画期间,imageview的手势不起作用,ios,objective-c,animation,uiviewanimation,Ios,Objective C,Animation,Uiviewanimation,我正在实现一个imageView的动画。在这个动画中,我的气球图像是从下到上的,如果用户要触摸气球,我想将其隐藏。但是我的手势在动画过程中不起作用。有人能帮我吗。提前谢谢 img=[[UIImageView alloc]init]; img.frame=CGRectMake(150, 450, 50,50); [self.view addSubview:img]; img.image=[UIImage imageNamed:@"ballon3.png"];
img=[[UIImageView alloc]init];
img.frame=CGRectMake(150, 450, 50,50);
[self.view addSubview:img];
img.image=[UIImage imageNamed:@"ballon3.png"];
img.userInteractionEnabled=YES;
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom:)];
tapGestureRecognizer.numberOfTapsRequired=1;
tapGestureRecognizer.delegate=self;
[img addGestureRecognizer:tapGestureRecognizer];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationRepeatCount:30];
[UIView setAnimationDuration:10];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
CGAffineTransform scaleTrans =
CGAffineTransformMakeScale(2, 2);
CGAffineTransform rotateTrans =
CGAffineTransformMakeRotation(angle * M_PI / 180);
img.transform = CGAffineTransformConcat(scaleTrans, rotateTrans);
img.center = CGPointMake(30,320);
这是手势的方法。但此方法未调用
-(void)handleTapFrom:(UIGestureRecognizer *)sender
{
img.hidden = yes;
}
您需要为动画使用块,以便喜欢:(注意
UIViewAnimationOptionAllowUserInteraction
,这很重要)
我让你设置你想要的其他参数
如果需要在iOS 4.0之前工作,则需要在单独的线程中设置动画 尝试NSLOg,如果控件正在那里,它是否在动画之外工作?如果没有,试着检查一些事情:-你的img使用的是强指针吗?-viewcontroller是否实现UIGestureRecognitzerDelegate?
[UIView animateWithDuration:10 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{
// Your animation here
} completion:^(BOOL finished) {
// Once completed do stuff here;
}];