1

I have UICollectionView inside UITableViewCell. If I make the size of the CollectionviewCell as custom and provide fixed width then it works fine.

But if I make it automatic and assign size in the delegate then it doesn't work. It takes the default width i.e 50.

Can you please help me out? Thanks

Code for changing size:

extension BeInspiredTVC : UICollectionViewDelegate , UICollectionViewDelegateFlowLayout{

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

        return CGSize(width: UIScreen.main.bounds.width - 50, height: 224)
    }

}

I want a full width Collectionviewcell but I am getting like the image below.

enter image description here

1 Answers1

0

take collection view width constraint

next assign self.contentView.frame.width to that constraint in layoutsubsview in tableview cell.

Sahil Omer
  • 73
  • 9
  • Thanks for the reply. Actually the CollectionView width is fine, but the CollectionviewCell width is not changing if I make it automatic. – user8591342 Dec 15 '20 at 11:25