views:

99

answers:

1

I have a block of content (stored in XML) that I want to put in a UIScrollView. Certain parts of this text will be formatted with different fonts, sizes, and colors. Altogether, it mostly reads as a paragraph with word wrapping.

I've built my NSXMLParser code, and I have separated all the data. I'm ready to apply my decorations and add these elements as UILabels.

However, I'm looking for a solution to ease the inherent difficulties of string height/width calculations and all of that arithmetic to make these UILabels line up with word wrapping nicely. [keeping track of your last X and Y coordinates, knowing when to insert manual line breaks, how to best vertically display a line that has 2 different sized fonts]

The XML markup can easily be converted to HTML, and thus UIWebView, but I hear that is slower to load.

Is the UIWebView going to be the best class for this? I wish there were one that did all of this with UILabels so that I can use these elements for touch events. (I assume that I cannot use an HTML element to trigger a touch event.)

+1  A: 

You should probably a UIWebView. You can use an HTML anchor for touchable elements. The delegate will give you the option of doing something other than loading a web-page when the user touches the element. You can use a made-up URL format to uniquely identify each element.

Aside from that, you may want to use a custom control that draws all the text, rather than a series of UILabels. The UILabels will probably make it difficult to do line wrapping.

Dustin Voss
I already spent a lot of time doing the UILabels on something else earlier, and I'm glad to know it was a waste of time--really--that can be best news sometimes.
ojreadmore