2010-01-04 72 views

回答

3

當UIImageView動畫完成時,您不會收到通知。你應該使用NSObject的performSelector:withObject:afterDelay:方法來安排一些代碼在時間完成後執行,但它不會是完美的。

1

很老的問題,但我需要一個修復現在,這個工作對我來說:

[CATransaction begin]; 
[CATransaction setCompletionBlock:^{ 
    DLog(@"Animation did finish."); 
}]; 

UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.window.bounds]; 
imageView.animationDuration = 0.3 * 4.0; 
imageView.animationImages = @[[UIImage AHZImageNamed:@"Default2"], 
           [UIImage AHZImageNamed:@"Default3"], 
           [UIImage AHZImageNamed:@"Default4"], 
           [UIImage AHZImageNamed:@"Default5"]]; 
imageView.animationRepeatCount = 1; 
[self.window addSubview:imageView]; 

[imageView startAnimating]; 

[CATransaction commit];