我正在使用惰性表下载图像并将图像保存在文件夹中。图像显示在表格 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/