1

我的程序不断崩溃:

-(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];
}

}

我究竟做错了什么?

4

2 回答 2

4

嗯,是的,因为setAnimationDidStopSelector:withObject:方法不存在...... UIView 的实际方法是: + (void)setAnimationDidStopSelector:(SEL)selector

(注意withObject:部分丢失)

于 2012-07-02T09:34:30.327 回答
3

检查文档setAnimationDidStopSelector方法。

动画结束后发送给动画代理的消息。默认值为 NULL。选择器应采用以下形式:

- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context.

因此,当您调用时,可以在方法中访问beginAnimations参数。contextanimationDIdStop

希望这可以帮助。

于 2012-07-02T09:45:28.020 回答