我有一个tableView,我从一个应用程序接口中填充图像,然而,它在滚动时会有相当大的滞后。我曾尝试在不同的线程上使用async & run,但无法正确使用。那么我该如何解决这个问题呢?这是我用来为每个单元格设置图像的cellForRowAt-func。
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "VideoCell", for: indexPath) as! TableViewCell
let video = highlightsArray[indexPath.row]
cell.video = video
do {
let url = URL(string: self.highlightsArray[indexPath.row].thumbnail)!
let data = try Data(contentsOf: url)
cell.thumbnailImage.image = UIImage(data: data)
}
catch{
print(error)
cell.thumbnailImage.image = UIImage(named: "pllogo.jpg")
}
return cell
}
发布于 2019-12-10 20:32:17
https://stackoverflow.com/questions/59267281
复制相似问题