I want to download an image to my tableViewCell but I only want the image downloaded to be inside a cell who is VISIBLE in my tableview. I want my tableView to download image when the tableviewcell is visible and during that time to display a loading bar or something until the download is finished and then display that image to the corresponding tableviewcell
This is the code I use to display image to tableviewcell:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("ContentCell", forIndexPath: indexPath)
let contentCell = cell as! ContentCell
contentCell.thumbnail.kf_setImageWithURL(self.contentArray[indexPath.row].thumbnailUrl)
print("row: \(indexPath.row)")
return contentCell
}
What I get is all the image is download all at once. I know this because When I scroll down I find that all the image is instantly displayed without delay even though my logging method print() only print visible cell's row.
Am I implementing this wrong?