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:
and this is how they look after I make the first scroll
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
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
}