I have a UITextView that displays text longer than what can be fit into the textview's frame. I want the text to be truncated by showing ellipsis on iOS 6.
On iOS 7 I am able to achieve this by using the following code
textView.textContainer.maximumNumberOfLines = 0;
textView.textContainer.lineBreakMode = NSLineBreakByTruncatingTail;
On iOS 6 I am able to truncate the text but it doesn't display the ellipsis.
Problem is on iOS6 the property textContainer is not available
Pls Note:
Question
On iOS 6 how would I be able to show the ellipsis ?
Thanks all, @matt helped me find my solution.
I suppose the best fit for my problem is using a UILabel instead.
The only problem I was facing with UILabel and Autolayout was that when the text is just one line, the text was center aligned vertically and it looked odd.
Solution (Autolayout and UILabel)
preferredMaxLayoutWidth to desired value. This is what I was really missingsizeToFit after setting the text and after orientation changeSo if the height returned by sizeToFit is a smaller height than the max height, then that size would be taken otherwise, max height set in step 3 would be taken
This works on both iOS 6 and iOS 7
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