title: UICollectionView adding image to a cell
body: <p>I'm working on a project which uses <code>UICollectionView</code> to display data which may or may not have an image.</p>
  
  <p>The way I'm using is to check if the image url is not null, then add an ImageView onto the cell.</p>
  
  <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  {
      if (question.picture != (id)[NSNull null]) {
          //add AsyncImageView to cell
          imageView.contentMode = UIViewContentModeScaleAspectFill;
          imageView.clipsToBounds = YES;
          imageView.tag = IMAGE_VIEW_TAG;
          [cell addSubview:imageView];
          [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView];
          imageView.imageURL = [NSURL URLWithString:question.picture];
      }
  }
  </code></pre>
  
  <p>For those cells that have no image, the cell should look like this:
  <a href="https://dl.dropboxusercontent.com/u/5753236/Stackoverflow/good.png" rel="noreferrer">https://dl.dropboxusercontent.com/u/5753236/Stackoverflow/good.png</a></p>
  
  <p>However, some of them will still add an ImageView with cropped image on it, causing something like this:
  <a href="https://dl.dropboxusercontent.com/u/5753236/Stackoverflow/bad.png" rel="noreferrer">https://dl.dropboxusercontent.com/u/5753236/Stackoverflow/bad.png</a></p>
  
  <p>I've tried using the SDWebImage, but still not solving the problem.</p>
  
  <p>The other issue is that when I scroll down the <code>UICollectionView</code>, I would see some images displayed as the image shown above first, and then change to its correct image after loading is completed, and I just have no idea what is causing the problem.</p>
  
  <p>Please help me sort out these two problems, I'd really appreciate for any help.</p>