我試圖在懶惰模式下加載我的uitableviewcells的圖像。在桌面視圖中加載圖像的延遲
我試圖以最簡單的方式做到這一點,我看到很多例子,但他們比我的目標更進一步。
這是林目前做的,它不工作:
// Configure the cell...
Info *info = [self.Array objectAtIndex:indexPath.row];
cell.textLabel.text = info.name;
cell.detailTextLabel.text = info.platform;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//The image is downloaded in asynchronous
NSBlockOperation *downloadingImgBlock = [NSBlockOperation blockOperationWithBlock:^{
NSString* imageURL = info.imgURL;
NSData* imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imageURL]];
cell.imageView.image = [UIImage imageWithData:imageData];
}];
[self.queue addOperation:downloadingImgBlock];
爲什麼它不工作?它是如何工作的?
難道你嘗試在主線程上設置圖像,調用dispatch_async並傳遞主線程 – rckoenes 2012-07-17 13:02:23
你有沒有試過Grand Dispatch呢? – holex 2012-07-17 13:09:00
對這兩個問題都沒有,你能告訴我怎麼做嗎? – 2012-07-17 13:10:35