AlamofireImage
でサーバからサムネイルをダウンロードして表示していますが、ダウンロードはうまく動作しますが、tableivewセルの画像が常に変化するときは検索していません。例えばprepareForReuse
カスタムセル呼び出しでここに私のコードです:AlamofireImageでテーブルビューのセル画像を表示する際の問題
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! TrendingCell
let trendingIndex = trendingArray[indexPath.row] as! [String:Any]
if let media = trendingIndex["thumbnails"] as? [String:Any] {
if let thumbnail = media["medium"] as? [String:Any] {
thumbnailURL = String(describing:thumbnail["url"]!)
}
}
Alamofire.request(thumbnailURL).responseImage { response in
if let image = response.result.value {
cell.thumbnail.image = image
}
}
return cell
}
ユーザーがテーブルビューをスクロールすると画像が変わるのを避けるにはどうしたらいいですか?
https://stackoverflow.com/questions/46199203/downloading-uiimage-via-alamofireimage/46199246#46199246 –
私はイメージのため、[SDWebImage](https://github.com/rs/SDWebImage)ライブラリを使用することをお勧めし – Srdjan
セルを使用して記述する必要があります。imageView –