【发布时间】:2017-09-14 13:19:25
【问题描述】:
当表格行进入视图时,我设法让一些代码在获取 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
}
}
}
【问题讨论】:
标签: ios swift swift3 alamofire alamofireimage