Get UITextView dynamic height with auto layout after setting text
If you prefer to do it all by auto layout:
In Size Inspector:
Set Content Compression Resistance Priority Vertical to 1000.
Lower the priority of constraint height for your UITextView. Just make it less than 1000.
In Attributes Inspector:
- Uncheck Scrolling Enabled.
All you have to do is:
- set up all your constraints except the height one AND
- set
textView
'sscrollEnabled
property toNO
The last part is what does the trick.
Your text view will size automatically depending on its text value.