Ios8 如何在UICollectionViewController中缓存图像
我正在开发图片库应用程序。在集合视图中,我显示拇指。每次,我滚动集合视图,应用程序读取并再次打开图像。一段时间后,会出现内存警告。我想缓存图像。然后,当我滚动集合视图时,应用程序读取缓存的图像,而不是打开一个新图像Ios8 如何在UICollectionViewController中缓存图像,ios8,Ios8,我正在开发图片库应用程序。在集合视图中,我显示拇指。每次,我滚动集合视图,应用程序读取并再次打开图像。一段时间后,会出现内存警告。我想缓存图像。然后,当我滚动集合视图时,应用程序读取缓存的图像,而不是打开一个新图像 - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { AllViewCell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
AllViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:IdAllCell forIndexPath:indexPath];
NSArray *arrInfo = [self.arrThangkaInfo objectAtIndex:indexPath.row];
// Cell Image
NSString *thumbImageName = [self getValue:@"thumb_image" forRecord:arrInfo];
NSString *imagePath = [NSString stringWithFormat:@"%@/%@", self.thumbFolder, thumbImageName];
UIImage *originalImage = [UIImage imageWithContentsOfFile:imagePath];
[cell.imageView setContentMode:UIViewContentModeScaleAspectFit];
[cell.imageView setImage:originalImage];
// Cell Label
NSString *name = [self getValue:@"name" forRecord:arrInfo];
[cell.nameLabel setTextAlignment:NSTextAlignmentCenter];
[cell.nameLabel setTextColor:[UIColor blackColor]];
[cell.nameLabel setBackgroundColor:[UIColor clearColor]];
[cell.nameLabel setText:name];
[cell setBackgroundColor:[UIColor clearColor]];
return cell;
}