0

I've come to the conclusion that the best way for me to display quite a bit of formatted text is using CoreText, although I've never used it, and it looks to be quite code-intensive for achieving results a basic word processor or HTML file would achieve easily!

Is this the way to go? I've already ruled out UIWebView due to Apple having issues with it, but can't seem to find any other viable alternatives to what seems to me to be quite a basic problem.

I'd love for someone on here to reassure me that all these apps in the App Store use CoreText to display all their formatted text and that I'm not being a complete idiot and missing something very obvious!

jscs
  • 63,694
  • 13
  • 151
  • 195
Giovanni
  • 850
  • 3
  • 14
  • 32

1 Answers1

0

It really depends on much control you need on text displaying . For something simple you can take a look at NSAttributedString class. See also Attributed String Programming Guide

yurish
  • 1,515
  • 1
  • 15
  • 16
  • Basically, I need the text to be similar in style to an official-looking one or two page document: headings, subheadings, a couple of highlights, a couple of paragraphs of normal text, etc. Once the text has been added by me, it wont be edited - its purely as a reference for others. CoreText just seems a very long-winded clunky way of achieving something pretty basic, am i right? – Giovanni May 21 '13 at 19:46
  • If I were you I would go the `NSAttributedString` way ;) It's much easier and does everything you need. – HAS May 21 '13 at 20:20
  • sorry to go on, but to help me on my way with NSAttributedString - I presume id have a separate one for each heading, sub-heading, block of text, etc (so i could format them all differently) and then load them all in order into a UITextView? Where is the best place to store the strings - in a txt file and import, or create them in code? as you can probably tell im quite new to this!! :) – Giovanni May 21 '13 at 20:31
  • You can use different formatting for ranges inside NSAttributedString. See for example [this](http://stackoverflow.com/questions/3482346/how-do-you-use-nsattributedstring). For iOS 6 or higher you can use the attributed string with UITextView or UILabel if you do not need editing. Also UIKit defines additions to attributed strings: http://developer.apple.com/library/ios/#documentation/uikit/reference/NSAttributedString_UIKit_Additions/Reference/Reference.html]. You can also try to find third-party component that inits attributed string from RTF file. – yurish May 23 '13 at 10:11