1) Override the collectionflowlayout delegate method
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSizeMake(50, 50);
}
2) In the above method, calculate the height of the text view that contains the dynamic length, and add this value to the fixed height. Ex. cellHeight = 100 + textview height. //100 is height which not contain textview height.
3) After calculating the height, replace it with the method described above
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSizeMake(50, dynamicheight);
}
source
share