0
 override func viewDidLoad() {
        let space:CGFloat = 10.0
        let dimensionwidth = (view.frame.size.width - (2 * space))
        let dimensionheight = (view.frame.size.height - (2 * space))

          flowLayout.minimumInteritemSpacing = space
          flowLayout.minimumLineSpacing = space
          flowLayout.itemSize = CGSize(width: dimensionwidth, height: dimensionheight)
        }

override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CellMemeCollection", for: indexPath) as! CellMemeCollection
        let Meme = self.memes[(indexPath as NSIndexPath).row]

        // Set the name and image
        cell.MemeImage?.image = Meme.memeImage
        cell.MemeImage.sizeThatFits(flowLayout.itemSize)

        return cell
    }

 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

     //    let height = view.frame.size.height
      //   let width = view.frame.size.width

        return CGSize(width: 200, height:400)
     }

I tried every thing that would make the photo looks bigger but nothing changing .. I played with the items size and I tried to call the function collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize but nothing is working , help please !

  • Maybe this will help: https://stackoverflow.com/questions/25895311/uicollectionview-self-sizing-cells-with-auto-layout – koen Dec 08 '19 at 14:25
  • is there an infinite ways to do that because I swear every website I checked has different solutions and none of them has worked for me ) : – Omar Aljoundi Dec 08 '19 at 14:41
  • Please add the code for `MemeImage`. First you set the image to `cell.MemeImage?.image`, but then you try `sizeThatFits()` with `cell.MemeImage`. Shouldn't that be `cell.MemeImage?.image` ? – koen Dec 08 '19 at 16:42
  • Did you set memeImage contentSize to .aspectFill ? – Celeste Dec 08 '19 at 18:31

0 Answers0