I've tried sizeWithFont:constrainedToSize:lineBreakMode
and sizeToFit
, both of which don't return the correct result.
The property contentSize
is supposed to return the correct height, but it doesn't work until the text view is rendered to the screen, and I need to calculate the height before the text view is visible (it determines the height of a UITableViewCell
.
Has anyone found any other method, a custom text view or the like, that correctly calculates the height of a UITextView?
EDIT I should clarify that I want the ideal height based upon the text view's content.
IOS 7 does not supports the property contentSize
anymore. Try using this
CGFloat textViewContentHeight = textView.contentSize.height;
textViewContentHeight = ceilf([textView sizeThatFits:textView.frame.size].height + 9);
this fixed my problem.
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