Manage Collection View height inside the Table View Cell using swift 4

Updated 26 October 2021


Collection View height inside the Table View Cell

In Most of time we use the collection view inside the table view cell if the collection view flow is vertical then we need to increase the height of table view cell or if flow layout is horizontal then we fix some constant height for table view cell .

Here I am discussing about how to manage the table view cell height automatically if collection view flow layout is vertical

Follow the Steps:

1: Go to Table view Cell class & create the outlet of collection view & collection view Height Constraints.

2: Now Register the Collection view cell so we can use .

3: Now write their All delegate & data source method inside the table view cell class.



4: Now the Collection View delegate & data source are set , now move to Table View Delegate & Data source.

5: Now register the tableview cell

6: After register the Tableview Cell & we have to define their delegate & Data source.

7: Now its Time to return the cell , here i am creating the vertical flow of collection view where the collection view height is fixed, so its automatically increase the table view cell size.


8 Notes : these are the important part to automate your table view cell

cell.frame = tableView.bounds



cell.productCollectionViewHeight.constant = cell.prodcutCollectionView.collectionViewLayout.collectionViewContentSize.height

9: Now your Table View Cell automatically increase without calculating the height of each collection view.




. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


  • ilham
    • kunal prasad (Moderator)
  • iBrahim
    • kunal prasad (Moderator)
    • kunal prasad (Moderator)
  • srikanth
  • Muhammed Eviz
  • Petfect answer
  • Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home