如何从内存中完全删除UIImageView动画? [英] How do I remove an UIImageView animation from memory completely?
本文介绍了如何从内存中完全删除UIImageView动画?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试释放我的应用程序内存,并希望在点击按钮时从内存中完全删除loadingImageView。我该怎么做?
I'm trying to free up my apps memory and want to completely remove loadingImageView from memory when I tap a button. How do I do this?
-(IBAction)animationOneStart {
NSMutableArray *images = [[NSMutableArray alloc] initWithCapacity:88];
for(int count = 1; count <= 88; count++)
{
NSString *fileName = [NSString stringWithFormat:@"testPic1_%03d.jpg", count];
UIImage *frame = [UIImage imageNamed:fileName];
[images addObject:frame];
}
loadingImageView.animationImages = images;
loadingImageView.animationDuration = 5;
loadingImageView.animationRepeatCount = 1; //Repeats indefinitely
[loadingImageView startAnimating];
[images release];
}
-(IBAction)removeFromMemory {
//What do I add here?
}
谢谢!
推荐答案
好的。如果你想删除UIImageView动画,试试这个:
Ok. If you want to remove UIImageView animation try this:
-(IBAction)removeFromMemory {
[loadingImageView stopAnimating]; //here animation stops
[loadingImageView removeFromSuperview]; // here view removes from view hierarchy
[loadingImageView release]; loadingImageView = nil; //clean memory
}
从UIView实例中删除CoreAnimation使用方法:
For remove CoreAnimation from UIView instance use method:
[view.layer removeAllAnimations];
这篇关于如何从内存中完全删除UIImageView动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文