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


Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s

%d 博主赞过: