Zeeshan Shaikh
Zeeshan Shaikh

Reputation: 103

Dynamic UITextView height in UITableView using auto layout?

I made a customCell and on that cell i have three UITextview and I want the textView to dynamically size itself when the remote text is filling up the all three UITextView, and I want the cell to dynamically size itself according to the textView. i saw many answers related to this but couldn't find any helpful solution for me, i'm using auto layout and made all the constrains and try every answer that i found in here but not solved yet, Would anyone please tell me any tutorial that i can follow or an easy step by step things for understanding how can i achieve the desired result, your help really appreciated

Please don't be too harsh cause I'm a beginner. Thanks

Upvotes: 0

Views: 808

Answers (2)

Jure
Jure

Reputation: 3043

Like Deepak said, you should set estimatedRowHeight to a value greater than zero and rowHeight to UITableViewAutomaticDimension.

Also, your vertical constraints should cover the whole cell.

For a more detailed explanation you can take a peak at a post I wrote which describes how to achieve a self-sizing text view with a working sample project.

Upvotes: 1

Deepak Kumar
Deepak Kumar

Reputation: 39

If you do the following things then it will work, - Use estimatedRowHeight on table view - Have proper constraints from top of the cell to the bottom so that auto layout engine can calculate the height properly - Content compression resistance priority on text views should be 1000

Upvotes: 0

Related Questions