如何从内存中完全删除UIImageView动画?

时间:2011-10-13 06:45:13

标签: ios

我正在尝试释放我的应用程序内存,并希望在点击按钮时从内存中完全删除loadingImageView。我该怎么做?

-(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?

}

谢谢!

1 个答案:

答案 0 :(得分:6)

确定。如果你想删除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];