Archive for the ‘Iphone’ Category

UITextView 显示 HTML

You must bother sometimes when you need to display a multi color text in your application! You must be using many uilabels with fissrent color. But you need not do this all. Here is a simple way to show your HTML file directly into UITextView.
What you need is to save all text into a html file and call that file in your UITextView with the help of this code bellow-
// Load the HTML source
self.sourceText = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@”htmlfile” ofType:@”html”]];
[myTextView setContentToHTMLString:self.sourceText];
You may download the sample app from here
Advertisements