iphone - 表格 View 图像应用程序中的内存警告 - 延迟下载

标签 iphone ios memory-leaks lazy-loading

我正在使用惰性表下载图像并将图像保存在文件夹中。图像显示在表格 View 中。

表格 View 一页有 36 张图片,大约有 10 页。

我一次又一次地收到内存警告。

谁能建议我如何解决这个问题?
因为我已经删除了所有对象,但问题还没有解决。

最佳答案

我认为你的代码有内存泄漏,你可以使用 profile(cmd + i) 检查它, 或者您可以这样尝试。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"cellIndentifier";
    UITableViewCell *cell;

    cell = [_tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
#else
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellIdentifier] autorelease];
#endif
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    } else {
        [[cell.contentView viewWithTag:999] removeFromSuperview];
    }

    //imageView
    UIImage *image = [UIImage imageWithContentsOfFile:@"filePath"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.tag = 999;
    [cell.contentView addSubview:imageView];
    [imageView release];

    return cell;
}

关于iphone - 表格 View 图像应用程序中的内存警告 - 延迟下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9081359/

相关文章:

iphone - 如何在collectionView中重新加载补充 View

ios - UIView 从右到左有动画

objective-c - ShareKit/Twitter 内存泄漏

linux - 如何发现进程的内存泄漏?

iphone - 如何检测 NSURLConnection sendAsynchronousRequest 是否完成

iphone - iOS PDF 表单字段

ios - UIDatePicker 在刷新之前显示不正确的分钟间隔

ios - UICollectionView 多重选择不会取消选择第一个单元格

iOS - 由于内存问题而终止

PHP Imagick 内存泄漏