2 yue1liang1chuan yue1liang1chuan 于 2013.04.27 11:21 提问

使用图形图片设置UIView缩略图

对一个UIView动画用图形context做了预览图片处理。

等到释放这个数组或者图片不需要再预览时,应该怎么释放内存?

用_pictureArray = nil?

- (NSMutableArray *)generateCachedImageArrayWithFilename:(NSString *)filename extension:(NSString *)extension andImageCount:(int)count
{
    _imagesArray = [[NSMutableArray alloc] init];
    _fileExtension = extension;
    _imageName = filename;
    _imageCount = count;
    for (int i = 0; i < count; i++)
    {
        NSString *tempImageNames = [NSString stringWithFormat:@"%@%i", filename, i];
        NSString *imagePath = [[NSBundle mainBundle] pathForResource:tempImageNames ofType:extension];
        UIImage *frameImage = [UIImage imageWithContentsOfFile:imagePath];
        UIGraphicsBeginImageContext(frameImage.size);
        CGRect rect = CGRectMake(0, 0, frameImage.size.width, frameImage.size.height);
        [frameImage drawInRect:rect];
        UIImage *renderedImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        [_imagesArray addObject:renderedImage];

        if (_isDoublingFrames)
        {
            [_imagesArray addObject:renderedImage];
        }
        else if (_isTripplingFrames)
        {
            [_imagesArray addObject:renderedImage];
            [_imagesArray addObject:renderedImage];
        }
        NSLog(@"filename = %@", filename);
    }
    return _imagesArray;
}
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!