当表格行进入视图时,我设法获取了一些代码,在其中获取Instagram图片的位置(通过Alamofire)。但是,一旦获取,我不希望再次调用表格行时再次进行调用。我怎样才能避免这种行为?当单元格在视图中时避免再次获取图像
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let url = places[indexPath.row].url
if let c = cell as? PlaceTableViewCell {
print("Downloading Image")
Alamofire.request(url, method: .get).responseImage { response in
guard let image = response.result.value else {
print("Error downloading image")
return
}
c.photoImageView.image = image
}
}
}
应该不会是“https://httpbin.org/image.png”,而不是“https://httpbin.org/image/png” – Miknash
顺便说一句。不知道关于AlamoFireImage,谢谢你的领导:) – Miknash
你介意告诉我如何去做我做过的事情,但用AlamofireImage +缓存。我自己尝试过一次,但由于某种原因无法启动它 – tommyd456