【发布时间】:2012-01-26 16:58:49
【问题描述】:
我在 ImageView 的层中添加了一个 CAKeyframeAnimation 来表示图像的动画:
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
animation.values = arrayOfImages;
[animation setRemovedOnCompletion:YES];
animation.delegate = self;
[animation setValue:delegate forKey:@"AnimatedImageViewDelegate"];
animation.repeatCount = repeatCount;
animation.fillMode = kCAFillModeForwards;
animation.calculationMode = kCAAnimationDiscrete;
[animation setValue:animationName forKey:@"name"];
当我想开始我调用的动画时:
animation.duration = duration;
[self.layer addAnimation:animation forKey:animationName];
[self.layer setContents:[animation.values lastObject]];
当动画完成后,我想将它完全移除并释放它的内存。
[self.layer removeAllAnimations];
[self.layer removeAnimationForKey:animationName];
这样做并使用 Instruments-Activity Monitor,除非我释放完整的 imageView,否则不会释放内存。
如何在不破坏 UIImageView 的情况下释放动画内存???
【问题讨论】:
-
你可以试试把它放到autoreleasepool中
标签: iphone cocoa-touch uiimageview core-animation cakeyframeanimation