将图像添加到cellForRowAtIndex时,TableView会变慢

时间:2016-05-02 13:38:07

标签: ios swift uitableview asynchronous

我有这一行代码,它是从API检索图像。然而,虽然这有效,但当我运行代码来检索图像时,应用程序运行速度很慢。

我正在使用UITableView。当我对代码进行评论时,它似乎运行顺畅,是否有更好的方法来使用此代码使应用程序运行得更快? 我的代码:

 if let data = NSData(contentsOfURL: NSURL(string:events[indexPath.row].image! )!) {
     cell.imageView!.image = UIImage(data: data)
 }

0 个答案:

没有答案