title: Adjusting UICollectionView size to fit UIImage
body: <p>I'm trying to adjust the cell heights to fit the UIImages, the problem is it does not seem like the UIImage is filling the collectionView cell. As you can see on this</p>
  
  <p>Image: <a href="http://oi61.tinypic.com/98d3zd.jpg" rel="nofollow">http://oi61.tinypic.com/98d3zd.jpg</a></p>
  
  <p>It seems like the cell adjusted, but the image is not filled correctly to fill the cell?</p>
  
  <p><strong>cellheights</strong>
  First I've created a loop which calculate the new height if the cellWidth is 140, which is the case allways.</p>
  
  <pre><code>for (int i = 0; i &lt; [homesDic count]; i++) {
  
      UIImage *originalImage = [[homesDic objectAtIndex:i] objectForKey:@"image"];
  
      CGFloat originalHeight = originalImage.size.height;
      CGFloat originalWidth = originalImage.size.width;
      CGFloat wantedWidth = 140;
      float wantedHeight = (originalHeight*wantedWidth)/originalWidth;
      [_cellHeights addObject:@(wantedHeight)];
  }
  </code></pre>
  
  <p>Then I insert a imageView in to the collectionView cell and set the frame and set cell height equal to the imageheight from the cellHeights array.</p>
  
  <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
                    cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  
      FRGWaterfallCollectionViewCell *waterfallCell = [collectionView dequeueReusableCellWithReuseIdentifier:WaterfallCellIdentifier indexPath];
      waterfallCell.lblTitle.text = [NSString stringWithFormat: @"Item %d", indexPath.item];
  
      waterfallCell.bottomView.backgroundColor = [UIColor colorWithRed:0.184 green:0.192 blue:0.196 alpha:0.7];
      waterfallCell.homeImage.image = [[homesDic objectAtIndex:indexPath.item] objectForKey:@"image"];
  
      waterfallCell.homeImage.frame = CGRectMake(0, 0, [self.cellHeights[indexPath.item] floatValue], waterfallCell.frame.size.width);
      return waterfallCell;
  }
  
  - (CGFloat)collectionView:(UICollectionView *)collectionView
                     layout:(FRGWaterfallCollectionViewLayout *)collectionViewLayout
   heightForItemAtIndexPath:(NSIndexPath *)indexPath {
  
      return [[self.cellHeights objectAtIndex:indexPath.item] floatValue];
  }
  </code></pre>