I have a UITextView not scrollable with auto layout set by interface builder, and the text increase or decrease dynamically with no problem, but i want know what is the new UITextView height after setting text, i'm trying to do this:
NSLog(@"text before: %.2f",self.myText.frame.size.height); [self.myText setText:self.string]; NSLog(@"text after: %.2f",self.myText.frame.size.height);
this is the result:
text before: 47.50 text after: 47.50
the text is increased in the view when i run it, but the size is the same, how i can get the real height after setting text?
All you have to do is:
textView
's scrollEnabled
property to NO
The last part is what does the trick.
Your text view will size automatically depending on its text value.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With