title: Handle loading & refreshing on a CollectionView Objective-C
body: <p>I am building an Xcode application that features a vertically scrolling <code>UICollectionView</code> of Views with large ImageViews in them, similar to Instagram.  This Collection View originally loaded very small images into the ImageViews in each UICollectionViewCell, making the app load fast and making the loading of individual cells instantaneous.  </p>
  
  <p>I recently made a change to the app that makes the Collection View Cells load much larger images into their Image View, which causes 2 things in some cells:</p>
  
  <p>1) A wait time where the ImageView is blank until the image is loaded</p>
  
  <p>2) Temporary repetition of old images in cells that have been reused from the queue while the new image is loading</p>
  
  <p>Below is the code that I use to initialize my cells:</p>
  
  <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  {
      UICollectionViewCell *cell;
      NSString *CellIdentifier;
      UIImageView *thumbnailImage;
  
      CellIdentifier = @"FollowersFeed"; 
      cell = [collectionView
  dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
      thumbnailImage=(UIImageView *)[cell viewWithTag:1];
      dict=[follwerFeed objectAtIndex:indexPath.row];
  
      NSString *nurl=[dict valueForKey:@"video"];
      [thumbnailImage setImageWithURL:[NSURL URLWithString:nurl]];
  
      //........
  
      return cell;
  
  }
  </code></pre>
  
  <p>In order to fix the functionality of this app with these new larger pictures, I need to solve the loading problem by </p>
  
  <p>1) Showing an Activity Indicator spinning while the Image View in a Collection View loads.</p>
  
  <p>2) Remove the image link from the previous Image View before the cell is reused in the queue.</p>
  
  <p>I believe that if I can figure out how to do both of these, then the app's scrolling will work just as seamlessly now as it was with the smaller images</p>