如何从内存中完全删除UIImageView动画?
问题描述:
我想释放我的应用程序内存,并希望从内存中完全删除loadImageView,当我点击一个按钮。我该怎么做呢?如何从内存中完全删除UIImageView动画?
-(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动画试试这个:
-(IBAction)removeFromMemory {
[loadingImageView stopAnimating]; //here animation stops
[loadingImageView removeFromSuperview]; // here view removes from view hierarchy
[loadingImageView release]; loadingImageView = nil; //clean memory
}
对于从UIView的实例使用的方法删除CoreAnimation:
[view.layer removeAllAnimations];
'loadingImageView.animationRepeatCount = 0; //无限重复# – beryllium