2012-01-20 9 views
1
//NsMutableArray 
//Received memory warning, while using animations in UIImageview like; 
self.imageArray = [[NSMutableArray alloc] initWithCapacity:IMAGE_COUNT]; 

// Build array of images, cycling through image names 
if (![self.imageArray count]>0) { 
    for (int i = 0; i < IMAGE_COUNT; i++){ 
     if (i<10) { 
     [self.imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image000%d.jpg", i]]]; 

     }else { 

     [self.imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image00%d.jpg", i]]]; 

     } 
    } 
} 

/////Received memory warning, while using animations in UIImageview 
self.animatedImages.animationImages = [NSArray arrayWithArray:self.imageArray]; 
[self.imageArray release]; 
self.imageArray=nil; 

// One cycle through all the images takes 1.5 seconds 
self.animatedImages.animationDuration = 0.8; 
// Repeat forever 
self.animatedImages.animationRepeatCount = -1; 
[self.animatedImages startAnimating]; 
+0

あなたの質問は? –

答えて

1

APIはimageNamedので

[UIImage imageWithData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle]pathForResource:[NSString stringWithFormat:@"image000%d.jpg", i] ofType:nil]]]; 

[UIImage imageNamed:[NSString stringWithFormat:@"image000%d.jpg", i]] 

を交換してください:メモリ上のキャッシュデータを。

+0

Rakeshに感謝します。すぐにデバイスで確認します。 – Wish

関連する問題