Iphone 执行这种类型的动画时是否有animationDidStopSelector?
我有一个UIimageView,它显示为静态图像。当触摸图像时,它会在该UIImageView中设置16个图像的动画。动画完成后,我想将UIImageView的图像设置为新图像。我不知道如何以我目前拥有代码的方式做到这一点。谁能告诉我怎么做?我曾尝试使用设置为动画持续时间的NSTimer来调用另一个方法,但这并没有真正起作用。这是我的密码。我非常感谢你的帮助Iphone 执行这种类型的动画时是否有animationDidStopSelector?,iphone,objective-c,ios,animation,Iphone,Objective C,Ios,Animation,我有一个UIimageView,它显示为静态图像。当触摸图像时,它会在该UIImageView中设置16个图像的动画。动画完成后,我想将UIImageView的图像设置为新图像。我不知道如何以我目前拥有代码的方式做到这一点。谁能告诉我怎么做?我曾尝试使用设置为动画持续时间的NSTimer来调用另一个方法,但这并没有真正起作用。这是我的密码。我非常感谢你的帮助 - (void) hdFallingAnim { NSString *fileName; NSMutableArray
- (void) hdFallingAnim {
NSString *fileName;
NSMutableArray *imageArray = [[NSMutableArray alloc] init];
for(int i = 1; i < 17; i++) {
fileName = [NSString stringWithFormat:@"FallingReg/HD_Falling_REG%d.png", i];
[imageArray addObject:[UIImage imageNamed:fileName]];
}
hdFalling.userInteractionEnabled = YES;
hdFalling.animationImages = imageArray;
hdFalling.animationDuration = 2;
hdFalling.animationRepeatCount = 1;
hdFalling.contentMode = UIViewContentModeCenter;
[self.view addSubview:hdFalling];
[hdFalling startAnimating];
}
目前还没有官方的方法来检测这类动画。您可以在后台线程中进行如下轮询:
dispatch_queue_t queue = dispatch_queue_create("waste.of.resources.but.it.works", 0);
dispatch_async(queue, ^{
while( [hdFalling isAnimating]) {
//Waiting....
}
//Finished
hdFalling.animationImages = nil;
hdFalling.image = //Your image
});
dispatch_release(queue);
我认为没有可靠的方法可以做到这一点。试试这篇文章,看看如何用核心动画制作图像动画。然后可以使用完成委托。