views:

206

answers:

2

Hello! I have about twenty UITextViews and corresponding .txt files. What I want is to make each UITextView take the contents of the corresponding file and display it. Moreover, the text is formatted and it contains some formulas (copy/pasted from Grapher). I've heard about displaying formatted text in UIWebView, but I haven't found a clear explanation anywhere.

Thanks in advance!

+1  A: 

Displaying formula in a UITextView will be difficult as the character rules for formula are completely different from language text. You could generate HTML to display it that but that is difficult as well.

I think your best bet would be to draw the formula to an image and then display the image. That is the traditional way to handle the display of formula.

TechZen
So you suggest to put the text and the formulas converted to images to UITextView? Anyway, I still can't make the UITextView read the text from file.
Knodel
To read text for a file use one of NSString's string from file methods. Then put that string into the UITextView.
TechZen
+1  A: 

Text files normally don't contain formatted text.

If by "formatted" you mean "html" then yes, you will want to use UIWebView. Basically you will convert the text to an HTML document, and then use the web view to display that document. There are several example projects available from Apple that show you how to use UIWebView.

Chris Garrett