views:

270

answers:

1

Hi,

im searching for a solution of the following problem:

i got a "larger" XHTML string that i want to display in an area that is scrollable. I already used TTStyledTextLabel for a small text-caption and it works pretty well.

But now i want display it more like a UITextView that scrolls or a UIScrollView with my TTStyled Content in it. i think TTStyledTextLabel isnt the right thing to view such a large (with large i mean about 900px height) content.

i need a TTStyledTextView, or something like that. Does something exist? How to work with it. My Content has a variable length so i cannot setup a UIScrollView with a TTStyledTextLabel in it.

Any hints for me ?

Thanks!

+3  A: 

You can determine the height needed to display the whole XHTML string by doing this:

htmlLabel.text = [TTStyledText textFromXHTML:htmlText];
[htmlLabel sizeToFit];
CGFloat height=htmlLabel.height;

I do this to create dynamic table cells that include these labels. You can use this height to set the contentSize of a parent scrollview.

You might however run into problems if your view is higher than 1024pixels on iPhone OS 2.x:

Note: Prior to iPhone OS 3.0, UIView instances may have a maximum height and width of 1024 x 1024. In iPhone OS 3.0 and later, views are no longer restricted to this maximum size but are still limited by the amount of memory they consume. Therefore, it is in your best interests to keep view sizes as small as possible. Regardless of which version of iPhone OS is running, you should consider using a CATiledLayer object if you need to create views larger than 1024 x 1024 in size.

Felix
so i should do such a large view with a label? isnt the logic of a label to display small amounts of text? or is this the only working element go get my xhtml displayed?
choise
I would give it a try. If performance trails behind you can still look for better alternatives.
Felix
Also TTStyledTextLabel does not inherit from UILabel
Felix
okay, thanks. you helped me a lot the last few days ;)
choise
you're welcome!
Felix