我的程序一直在崩溃:
-(void) moveImage:(UIImageView *)image duration:(NSTimeInterval)duration curve:(int)curve x:(CGFloat)x y:(CGFloat)y key:(NSString *)key
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:)];
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
image.transform = transform;
[UIView commitAnimations];
}
这被调用,完成后我想让它调用下面的方法:
-(void)animationDidStop:(NSString *)key
{
if (key == @"burn") {
//The burn card has been moved and stopped. Ready for the next.
[self annPlayerRight];
}
}
我做错了什么?
答案 0 :(得分:4)
嗯,是的,因为setAnimationDidStopSelector:withObject:
方法不存在...
UIView的实际方法是:
+ (void)setAnimationDidStopSelector:(SEL)selector
(注意withObject:
部分缺失)
答案 1 :(得分:3)
检查Documentation setAnimationDidStopSelector
方法。
动画结束后发送给动画代表的消息。默认值为NULL。选择器应采用以下形式:
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context.
因此,当您致电beginAnimations
时,可以使用context
方法访问参数animationDIdStop
。
希望这有帮助。