Tutorial :isAnimating return is faulty for UIImageView for iPhone



Question:

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?


Solution:1

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


Solution:2

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.


Solution:3

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

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »