isAnimating return is faulty for UIImageView for i

2019-03-02 13:26发布

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?

3条回答
ゆ 、 Hurt°
2楼-- · 2019-03-02 14:10

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];
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-03-02 14:12

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.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-03-02 14:30

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

查看更多
登录 后发表回答