novice
novice

Reputation: 451

Problem with custom tableview cell . Collectionview inside the custom tableview cell is not adjusting according th the height of cell

In the tableview i have a custom cell(which has a height of 500 in interface builder).Within that cell i have a collection view which i'm pinning to edges by (10,10,10,10) .But in tableview delegate method heightForCell: atIndexPath: I'm giving the height as 200. In the output i'm getting the cell height as 200 but the collectionview inside that cell is not rendering layouts according to 200(Which i took in code) but by 500(which i took in interface builder) taking height given in interface builder

Upvotes: 0

Views: 35

Answers (1)

Lê Công
Lê Công

Reputation: 21

you have to using delegate like tableview to change collection cell height

func collectionView(_ collectionView: UICollectionView, 
                      layout collectionViewLayout: UICollectionViewLayout, 
               sizeForItemAt indexPath: IndexPath) -> CGSize {
    return CGSize(width: 200, height: 200)
}

Upvotes: 1

Related Questions