I used the alamofire-image library to display an image from a url inside a uicollectionview cell.
I noticed that most of the time it displays the correct image, but sometimes it displays the wrong image (in most cases the previous image of the cell). how to overcome this problem.
func collectionView(collectionView: UICollectionView,
cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell",forIndexPath: indexPath) as! myCollectionViewCell
cell.titleLabelCell.text = element[indexPath.row]["title"]
cell.generLabelCell.text = element[indexPath.row]["gener"]
let URL = NSURL(string: "\(element[indexPath.row]["banner_site_url"])" )!
cell.mImageView.af_setImageWithURL(URL)
return cell
}
source
share