animating with UIImageview takes the following steps
- create autoreleased UIImageView
- create array of image
- assign the image array to UIImageView’s animationImages property
- set other properties
- add UIImageView to a view as subview
- startAnimating
I’m worried about memory leak.
Would the imageView get dealloc-ed as long as the UIImageView is autoreleased object?
It sounds like you want the image view to go away after the animation is complete. As it is, it will not. It will remain a subview. I’m not sure what it will look like when the animation is complete.
It’s not a memory leak per-se, since the view still has a pointer to the image view, but if you repeat the above over and over again you will have less and less memory. You need to remove the image view from its parent view at some point.
Probably what you can do is create an animation using
[UIView animateWithDuration:animations:completion:]. Give it a duration equal to the duration of your animated image. In the animations block do nothing. In the completion block remove the image view from its superview.Or just do performSelectorAfterDelay to call something that removes the view. Not sure if one will better guarantee synchronization with the animation of the sequence of images.