Reputation: 43
how can I learn total number of characters a UITextView shows in its specific contentSize after UILineBreakModeWordWrap applied.
I will use different strings everytime as the text of UITextView. The strings are much longer than UITextView with its specified area can contain. The visible characters will be different for every different string because of the different length of spaces at the end of the lines.
And I want to learn the number of characters visible in my UITextView.
Upvotes: 4
Views: 1170
Reputation: 568
Use this method from NSString:
- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode
It is a very intensive method but I think it's the only one (You can optimize it by adding/removing half of the remaining string instead of adding/removing characters).
Upvotes: 1