UITableView在XCode 7 Swift 2中与NSURLSession异步加载单元映像

时间:2015-09-22 19:24:53

标签: swift2 ios9 xcode7

有人可以发布示例代码,了解如何显示异步加载单元格图像的表格视图吗?

有很多Stack Overflow问题和博客文章,其中包含早期Swift版本的工作示例代码,但我找不到任何与Swift 2.0和XCode 7兼容的示例。

1 个答案:

答案 0 :(得分:0)

pinterest有一个很棒的库和#xA; https://github.com/pinterest/PINRemoteImage




 导入PINRemoteImage

 func tableView(tableView:UITableView,cellForRowAtIndexPath indexPath:NSIndexPath) - > UITableViewCell {

设j = MYCELLOBJECT![indexPath.row]
让c = tableView.dequeueReusableCellWithIdentifier(CUSTOMCell.id)为! CUSTOMCell

 c.Icon?.pin_setImageFromURL(NSURL(string:j.URLTOIMAGE),placeholderImage:UIImage(),processorKey:“Ball”,处理器:{(结果,成本) - > UIImage!in
 return result.image&# xA;
},完成:{(结果) - > Void in})

返回c

 }