title: Different UIImage sizes in custom UITableViewCell
body: <p>I am downloading a number of images from the internet, from several different locations, all with unknown and differing dimensions.</p>
  
  <p>I have successfully got them all lazy loading nicely and appearing when downloaded in the custom UITableViewCell I created, which has a UIImageView (<code>cellImageView</code> width 320, height 100) inside it.</p>
  
  <p>I am setting the Table's cell and resizing the row height like so:</p>
  
  <pre><code>- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath: (NSIndexPath *) indexPath 
  {
      ImageDownloader *download = [imagesModel.downloads objectAtIndex:[indexPath row]];
  
      if (download.image) 
      {
          CGFloat scaleFactor = 320.0f / download.image.size.width;
          CGFloat heightScaled = (scaleFactor * download.image.size.height); 
  
          return heightScaled;
      }
          return 100.0f;
  }
  
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
  {
      ImageTableCell *cell = (ImageTableCell *)[tableView dequeueReusableCellWithIdentifier:[ImageTableCell reuseIdentifier]];
  
      if (cell == nil) 
      {
          [[NSBundle mainBundle] loadNibNamed:@"ImageTableCell" owner:self options:nil];
          cell = loadCell;
          self.loadCell = nil;
      }
      ImageDownloader *download = [imagesModel.downloads objectAtIndex:[indexPath row]];
  
      if (download.image == nil)
      {
          download.delegate = self;
      }
  
      cell.cellImageView.image = download.image;
  
      return cell;
  }
  </code></pre>
  
  <p>Problem is I can't get the cells to display correctly. I have played around with the contentMode of the UIImageView and found the AspectFill works OK but pushes everything upwards causing clipping and masking and stretches some images when they shouldnt be. Using Top solves the vertical problem but the TableViewCell then doesn't fit the image (the image is too big sometimes.</p>
  
  <p>Is the solution is to resize the Table's row, the custom TableViewCell, the UIImage <strong><em>and</em></strong> UIImage? And maybe create my own scaling functionality? </p>