I need to render an (arbitrarily large) NSAttributedString
, in this case ANSI-colored text from an (arbitrarily long) telnet session. The text need not be editable inline. I have explored a few options:
UITextView
seems to have by far the best performance and, since I'm targeting iOS 6, it's very easy to use with attributed strings. However, the textview gets progressively slower to render as more text is added, as it hits an HTML DOM parser each time I call setAttributedString:
and blocks the UI. TTTAttributedLabel
and OHAttributedLabel
, that also get progressively slower with more text. To be fair, they're labels probably not intended for this sort of thing!UIWebView
(gag) has some issues with rotation and keeping the text properly sized and framed, but I think I could work around it. I can convert my attributed string to HTML and use JavaScript to append (inject) new text as it is received. Surprisingly good performance here. So I turn to you, brave interwebs. Ideas for an indie developer? Is a webview my best bet?
You could use a UITableView and split the NSAttributedString
into an array of substrings that would each fit a cell's label width. The table view's data source would index into the array of substrings to determine which line of the original string should be placed in each cell.