In Swift, Dynamic Height for UItextview in UIcollectionview

Swift: Dynamically Size UICollectionViewCell

It's possible that while you are setting the width to 80% inside of your estimatedFrame function that you are not factoring in the padding within the UITextView and that the slight difference in available width in the textview vs the 80% calculation is resulting in a different height being calculated.

How to set UITextView's height dynamically in UITableViewCell based on string size?

When using Auto-Layout for dynamically sizing cells, you don't really need to implement sizeThatFits(...). If the constraints are setup correctly, then you only need to disable the scrolling of the UITextView.

From code:

yourTextView.scrollEnabled = false

From IB:

Select your Text View and open Attributes inspector, then

Sample Image



Related Topics



Leave a reply



Submit