Iphone 如何检查UIImageView是否已完成其动画

Iphone 如何检查UIImageView是否已完成其动画,iphone,objective-c,cocoa-touch,uiimageview,Iphone,Objective C,Cocoa Touch,Uiimageview,我是iPhone开发新手。我正在使用UIImageView为数组中的图像设置动画。我决定通过名为isAnimating的属性停止动画。但它总是返回真实 我想检查动画是否已完成,或者是否还有一些时间来完成动画 请告诉我,我如何检查它。您应该在动画块中制作动画: [UIView animateWithDuration:duration animations:^{ //animation code here } completion:^(BOOL finished) { //this

我是iPhone开发新手。我正在使用
UIImageView
为数组中的图像设置动画。我决定通过名为
isAnimating
的属性停止动画。但它总是返回真实

我想检查动画是否已完成,或者是否还有一些时间来完成动画


请告诉我,我如何检查它。

您应该在动画块中制作动画:

[UIView animateWithDuration:duration animations:^{
    //animation code here
} completion:^(BOOL finished)
{
    //this will be called when the animation is finished
}];

编辑:这个答案是错误的,可能不应该被接受,因为任何来这里寻找正确答案的人:回答这个问题我认为你应该在动画块中制作动画:

[UIView animateWithDuration:duration animations:^{
    //animation code here
} completion:^(BOOL finished)
{
    //this will be called when the animation is finished
}];

编辑:这个答案是错误的,可能不应该被接受,因为任何来这里寻找正确答案的人:回答这个问题,我认为 然后执行此代码

{
     [UIView beginAnimations:@"Animation of ImageVIew Begins" context:nil];
           IsAnimating =YES;

     [UIView setAnimationDuration:0.4]; //you can put your time
     NSLog(@" Animating");
     [UIView setAnimationDelegate:self];
     [UIView setAnimationDidStopSelector:@selector(AnimationComplete)];

// Your animation code here     
     [UIView commitAnimations];
}


- (void) AnimationComplete
{
  isAnimating = NO;
}

在动画完成之前,BOOl变量将是YES。然后它将变为NO

使属性BOOl成为动画 然后执行此代码

{
     [UIView beginAnimations:@"Animation of ImageVIew Begins" context:nil];
           IsAnimating =YES;

     [UIView setAnimationDuration:0.4]; //you can put your time
     NSLog(@" Animating");
     [UIView setAnimationDelegate:self];
     [UIView setAnimationDidStopSelector:@selector(AnimationComplete)];

// Your animation code here     
     [UIView commitAnimations];
}


- (void) AnimationComplete
{
  isAnimating = NO;
}

在动画完成之前,BOOl变量将为“是”。然后它将变为“否”

使用基于持续时间的委托来触发接收器上所需的任何方法。

使用基于持续时间的委托来触发接收器上所需的任何方法。

能否显示动画代码,以便我们可以更好地提供帮助?您可以吗展示你的动画代码,这样我们可以更好地帮助你?我会投这个票-如果不坚持的话,我会投这个票-如果不坚持的话,我会投这个票-如果不坚持的话,我会投这个票,我知道,
animateWithDuration:completion:
用于制作iOS动画(如alpha淡入、运动、缩放、旋转等)我看到他接受了这个答案,但我相信最初的问题与通过设置
animationImages
属性来检测
UIImageView
设置UIImages数组动画的结尾有关。我很想看到一个关于如何检测动画结束的答案。我知道,
animateWithDuration:completion:
用于制作iOS动画(如alpha淡入、运动、缩放、旋转等)。我看到他接受了这个答案,但是我相信最初的问题与通过设置
animationImages
属性来检测
UIImageView
的末尾有关。我很想看到一个关于如何检测动画结束的答案。