Incorrect loading of an Alamofire image inside a uicollectionview cell

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
      }
+4
source share
1 answer

You must break the connection with any image upload request that may be executed when the cell is reused.

You can find a good tutorial written by Todd Kramer at:

, Swift Alamofire: 1

PhotoCollectionViewCell. - reset, , .

, , , , .

.

+4

All Articles