1

I am finding that isAnimating is returning true even after it has completed the max # of loops and stopped animating. However once you move the UIImageView, it will suddenly update and change to false.

Here are the important bits of my code: I set up the animation in the standard way:

UIImageView* newImageView = ...
newImageView.animationImages = imageArray;
newImageView.animationDuration = 1.0;
newImageView.animationRepeatCount = 1;
...
[newImagView startAnimating];

Elsewhere in the code I am checking whether the animation has come to completion with:

if (not [newImageView isAnimating])
{
...
}

Seconds after the animation has stopped, isAnimating will still return true.

However if the newImageView has been updated in some way (in my case moving it), it will suddenly return false. Which seems unrelated, and points towards this being a bug.

Has anyone run into this or know a work around?

Alex
  • 1,977
  • 3
  • 13
  • 20

3 Answers3

0

I tested it compiling with iphone 4.1 SDK and runngin thaton a 3.1.x device.

isAnimating on device works but not with any iphone simualtor 3.2,4.0,4,1

festival
  • 46
  • 1
0

I'm finding that isAnimating works only when built with pre-4.x iOS. If I build against 4.3, it doesn't change values unless any view gets tapped or the orientation changes. WIth 3.x isAnimating reliably changed value to NO once the animation had ended.

mahboudz
  • 39,196
  • 16
  • 97
  • 124
0

I ran into a similar problem. With code like yours I would the following after the animation duration.

[newImageView isAnimating] => true    # On the device (iOS5)
[newImageView isAnimating] => false   # On the simulator - this was what I expected (iOS5)

The following workaround seemed to work (though this seems like an iOS bug to me)

UIImageView* newImageView = ...
newImageView.animationImages = imageArray;
newImageView.animationDuration = 1.0;
newImageView.animationRepeatCount = 1;
...
newImageView startAnimating];
// Set a delayed call to stopAnimating
[newImageView performSelector:@selector(stopAnimating) withObject:nil afterDelay:1.01];
Geoff Evason
  • 461
  • 3
  • 5
  • The problem with this approach is that you have might be stopping the wrong animation. Image that you have more than one set of animationImages for the same imageView. If you tap quickly and start the second set of animations then you will be scheduling stopAnimating twice. You'd have to build state management... Yuck... – nicktmro Feb 08 '12 at 13:26