我加載圖像到的tableView,每次函數如何做到多線程將圖像加載到tableView更快?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
被執行時,圖像的不同的URL會..
我的問題是其採取了這麼多時間來加載圖像..
我的代碼..
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
self.tableView1 = tableView;
static NSString *simpleTableIdentifier = @"SimpleTableCell";
SimpleTableCell *cell = (SimpleTableCell *)[tableView1 dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.nameLabel.text = title;
NSString *imageURL = [NSString stringWithFormat: @"http://www.xyz.com/image1.png];
cell.thumbnailImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:fullURL]]];
}
return cell;
}
每次圖像URL會改變,這將需要時間來加載每個圖像..
任何人都可以提出任何想法來解決這個問題? 多線程如何使用此代碼? 哪裏,我應該在代碼中編輯?
https://github.com/rs/SDWebImage – janusbalatbat 2013-03-07 11:51:30