I cant display 3 cell in CollectionView [closed]

UICollectionViewDelegateFlowLayout

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath:NSIndexPath)->UICollectionViewCell
 {
    let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: "formCell", for: indexPath)
    return cell
}

For number of item

 func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int 
{
  return 3
}

For Get 3 cell in one row

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize 
    {
       let yourWidth = collectionView.bounds.width/3.0
       let yourHeight = yourWidth

       return CGSize(width: yourWidth, height: yourHeight)
    }

Leave a Comment