2011-10-13 40 views
0

我想釋放我的應用程序內存,並希望從內存中完全刪除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? 

} 

謝謝!

+0

'loadingImageView.animationRepeatCount = 0; //無限重複# – beryllium

回答

5

好的。如果你想刪除的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]; 
+0

不要忘了添加'QuartzCore'框架和'#import ' – beryllium

+0

謝謝,但那不行......不幸的是。 – dot

+0

我已編輯答案。現在檢查 – beryllium