我从api获取图片网址。我必须在我的uitableview单元格中加载这些图像。所以,当我滚动我的桌面视图时,它变得缓慢而且很难吃。
所以如何加载图像时能够快速滚动
这是我的代码:
let cell : seperatecell = tableView.dequeueReusableCellWithIdentifier("seperatecell") as! seperatecell
let dic : NSDictionary = mylistarray.objectAtIndex(indexPath.row) as! NSDictionary
cell.lbldate.text = dic["date"] as? String
// cell.lblsummary.text = dic["excerpt"] as? String
cell.lbltitle.text = dic["title"] as? String
// print(dic["attachments"])
let total = dic["attachments"]!.count
if (total > 0)
{
let myarray : NSMutableArray = (dic["attachments"] as? NSMutableArray)!
//print(myarray)
let dic1 : NSDictionary = myarray.objectAtIndex(0) as! NSDictionary
//print(dic1)
var newimage : String = ""
newimage = dic1["url"] as! String
if let url = NSURL(string: newimage) {
if let data = NSData(contentsOfURL: url) {
cell.image1.image = UIImage(data: data)
}
}
}
else
{
print("nil")
}
viewparent.hidden = false
EZLoadingActivity.hide()
return cell
答案 0 :(得分:1)