【发布时间】:2011-02-20 15:44:39
【问题描述】:
编辑: 在阅读了下面的答案并查看了我现在迷路的所有指南之后,我太菜鸟了,无法弄清楚。
我不想为我完成编码,我需要一些关于如何设置单独线程然后将其引用到我的 tableView 的明确建议。
有适合新手的教程吗?!?
这是我设置的用于将图像放入 tableView 的代码。所有图像都会加载,但仅在滚动表格时加载。
如何阻止这种情况?
任何帮助将不胜感激。
NSString *userImage = [(Tweet*)[profile objectAtIndex:indexPath.row] profileImage];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:[(Tweet*)[profile objectAtIndex:indexPath.row] profileImage]]];
dict =[[NSMutableDictionary alloc]init];
//UIImage *retImage =[dict objectForKey:(@"%@", userImage)];
UIImage *retImage =[dict objectForKey:userImage];
dispatch_async(dispatch_get_main_queue(), ^{
if (!retImage) {
UIImage *profileImage=[UIImage imageWithData:imageData];
[dict setObject:profileImage forKey:userImage];
}
UIImage *retImage2 =[dict objectForKey:userImage];
photo.image = retImage2;
[imageData release];
});
【问题讨论】:
-
您在问一个特定于表格视图的问题,但您没有显示用于填充/创建单元格的代码 - 在大多数情况下,UITableViewCells 设置不当是滚动缓慢的原因(例如使用透明胶片)。您应该引用 tableView:cellForRowAtIndexPath:indexPath 的代码,因为这很可能是一个关键因素。
-
当我在我的电脑上时,我会复制它
标签: iphone image url uitableview nsmutabledictionary