0

I have been having problems with my NSMutableAttributedString. I have a UITextView object with wrapping enabled, and it can hold 80 characters per line. I want to set the attributed text of the UITextView. My attributed string contains 85 'space' characters, and the letter 'A' at the end. I want the characters to wrap on the textview, but the 'A' is always pushed to left of the second line, as if some spaces were being trimmed.

NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"//85 characters of space and an A here"];

textview.setAttributedText = str;

When I do this, the spaces show just fine in the first line, but when it wraps, it has problems. Any ideas? Thanks in advance!

Michael Morrow
  • 403
  • 2
  • 16
  • What are you really trying to achieve here? The wrapping behavior of UITextView is always going to be a black box to you, so if you're not satisfied with how it works, you'd be better off looking for other ways to achieve whatever result you're trying to achieve. – ipmcc Aug 22 '13 at 15:41
  • I'm developing a terminal emulation app that needs to display multiple lines of blank characters. – Michael Morrow Aug 22 '13 at 15:50
  • I need to use attributed strings for underline, highlight and color – Michael Morrow Aug 22 '13 at 15:51
  • Using a UITextView to develop a terminal emulation app is a waste of time. I suspect you drastically underestimate the complexity involved -- UITextView is not going to give you nearly enough control. – ipmcc Aug 22 '13 at 18:35
  • I was able to do enough work arounds by creating a custom textview that subclasses UITextView. I override all methods and simply use it for detecting if the user is scrolling. I implement my own scrolling functionality and everything else works I just need to implement display enhancements. – Michael Morrow Aug 22 '13 at 21:52

0 Answers0