title: UICollectionView right height cell overlap
body: <p>I'm new building UICollectionView and I have an issue. I would like to display images that have 300px width and calculate the right height scale. To do this, I did :</p>
  
  <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath];
  
  UIImage *image = [photos objectAtIndex:indexPath.row];
  if(image){
  
      UIImageView *imageView = [[UIImageView alloc]initWithImage:image];
  
      float scale = (image.size.height/image.size.width)*300;
  
      [imageView setFrame:CGRectMake(imageView.frame.origin.x, imageView.frame.origin.y, 300, scale )];
  
      [cell addSubview:imageView];
      cell.backgroundColor = [UIColor clearColor];
  }else{
  
      cell.backgroundColor = [UIColor redColor];
  }
  
  
  return cell;
  }
  
  - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
      UIImage *image = [photos objectAtIndex:indexPath.row];
      float scale = (image.size.height/image.size.width)*300;
      return  CGSizeMake(300, scale);
  }
  </code></pre>
  
  <p>This seems to work at the beginning but as soon as I scroll down, images start to overlap each others. Is that any way to avoid this ?</p>
  
  <p><img src="https://i.stack.imgur.com/430JO.jpg" alt="enter image description here"></p>