目标C - 如何知道动画何时完成(UIImageview)

时间:2014-01-06 01:35:58

标签: ios objective-c

我有动画的代码:

facebookImage.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"Animation01.png"],
                                 [UIImage imageNamed:@"Animation02.png"],
                                 [UIImage imageNamed:@"Animation03.png"],
                                 [UIImage imageNamed:@"Animation04.png"],
                                 [UIImage imageNamed:@"Animation05.png"],
                                 nil];
facebookImage.animationDuration = 1.3;
facebookImage.animationRepeatCount = 1;
[facebookImage startAnimating];

如何在完成此动画后使用委托回调(或其他内容)来执行某些操作?

我不能这样做:

[UIView setAnimationDelegate:self];

因为我在UIImageview

中没有此选项

谢谢:)

1 个答案:

答案 0 :(得分:0)

只需添加如下:

float animationDuration = 1.3;
facebookImage.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"Animation01.png"],
                                 [UIImage imageNamed:@"Animation02.png"],
                                 [UIImage imageNamed:@"Animation03.png"],
                                 [UIImage imageNamed:@"Animation04.png"],
                                 [UIImage imageNamed:@"Animation05.png"],
                                 nil];
facebookImage.animationDuration = animationDuration;
facebookImage.animationRepeatCount = 1;
[facebookImage startAnimating];
[self performSelector:@selector(someMethodDelayedToEndOfAnimation) withObject:nil afterDelay: animationDuration];