Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 触摸按钮时重新启动动画_Iphone_Cocoa Touch_Animation_Uiimageview - Fatal编程技术网

Iphone 触摸按钮时重新启动动画

Iphone 触摸按钮时重新启动动画,iphone,cocoa-touch,animation,uiimageview,Iphone,Cocoa Touch,Animation,Uiimageview,我需要在单击按钮时重新启动动画 这是“我的动画”的代码: imgStar.frame = CGRectMake(205, 6, imgStar.frame.size.width, imgStar.frame.size.height); [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1.5]; [UIView setAnimationDelegate:self]; [U

我需要在单击按钮时重新启动动画

这是“我的动画”的代码:

imgStar.frame = CGRectMake(205, 6, imgStar.frame.size.width, imgStar.frame.size.height);    
[UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.5];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
    imgStar.transform = CGAffineTransformMakeTranslation(-4, 340);
    [UIView commitAnimations];
问题是:当我再次单击我的按钮时,动画不起作用

你能帮帮我吗?

我发现了问题。 错误是imgStar.transform。我尝试使用以下代码:

[imgStar setFrame:CGRectOffset([imgStar frame], -4, 340)];
而不是

imgStar.transform = CGAffineTransformMakeTranslation(-4, 340);

现在它工作了

为什么第二次的动画不起作用?