画像のアニメーションを表すために、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を破壊せずにそのアニメーションメモリを解放するにはどうすればよいですか???