2014-01-06 39 views
0

我有这样的代码为我的动画:目标C - 如何知道什么时候动画完成(的UIImageView)

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

谢谢:)

+0

实际上'UIImageView'是'UIView'的一个子类,因此它继承了'setAnimationDelegate:'。 – Espresso

+0

检查此问题http://stackoverflow.com/questions/9283270/access-method-after-uiimageview-animation-finish希望它可以帮助你 – stosha

+0

http://stackoverflow.com/questions/7772988/ios-how-to-detect - 当动画完成 – Jessedc

回答

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]; 
+0

谢谢 - Refael.S - 它的工作原理,但如果我想要运行这样的方法,我该如何传递参数: - (IBAction)movingObjectDown:(UIImageView *)myObj –

+1

尝试使用像[self performSelector:@selector(movingObjectDown :) withObject:myObj afterDelay:animDuration]; –

+0

首先moveObjectDown接收UIImageView,因此将其表示为IBAction是没用的,没有按钮会调用此操作。它会起作用,因为IBAction也是无效的。只需将其更改为void并执行[self performSelector:@selector(movingObjectDown :) withObject:myObj afterDelay:animDuration];作为评论已经(; –

相关问题