【发布时间】:2014-02-13 22:29:00
【问题描述】:
我正在尝试以惰性模式加载我的 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并通过主线程
-
你试过Grand Dispatch了吗?
-
两个问题都没有,你能告诉我怎么做吗?
标签: iphone objective-c ios