1

I am currently making a uiCollectionview that get the last photos from the user gallery, when I load the images they stay on a size similar to the view, but as soon I scroll they got a size increase and fit the view controller. as you can see this is the size of the images when the view is load: enter image description here

and this is how they look after I make the first scroll enter image description here

I Like how they look after the scrolling but I have no Idea why this is happening, the constrain the image are 0 to each side of the cell.

I am currently using this solution to get the image from the gallery https://stackoverflow.com/a/51172065/10360601

  • The Constraints: enter image description here

My Code:

class imageCollectionCellViewController: UICollectionViewCell {
    
    @IBOutlet weak var image: UIImageView!
}

The delegate to set the image:

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "busImageCollectionCell", for: indexPath) as! imageCollectionCellViewController
    
    photoLibrary.getImage(albumId: albums[indexPath.section].id,
                                  index: indexPath.item, userInfo: nil,
                                  targetSize: CGSize(width: 100, height: 100),
                                  deliveryMode: .fastFormat,
                                  resizeMode: .fast) { [weak self, weak cell] (image, userInfo) in
                                    cell?.image?.image = image
            }
    return cell
}
DonMag
  • 69,424
  • 5
  • 50
  • 86
Ricardo Guerrero
  • 433
  • 1
  • 5
  • 21

0 Answers0