tags:

views:

1392

answers:

2

hi, i tried the following one from iphone cook book .i displayed HTML content through accessing private API of UITextview like

 @interface UITextView (extended)
 - (void)setContentToHTMLString:(NSString *) contentText;
 @end

it works FINE.but Apple wont allow accessing private API.any solution pls?

+1  A: 

Do you want to display actual HTML elements or just a string you took off the web? For the latter, you would do the following:

NSURL *stringURL = [NSURL URLWithString:@"http://yoursite.com/page.html"];
NSString *responseString = [NSString stringWithContentsOfURL:stringURL encoding: NSUTF8StringEncoding error:nil];
myTextView.text = responseString;
Sam V
A: 

You could try using the Three20 library, which includes a styled text label:

http://github.com/facebook/three20/

The class TTStyledTextLabel of the Three20 framework has a text property "text" of type TTStyledText. This TTStyledText class has a textFromXHTML: static method which takes an NSString with any kind of HTML text inside, and might help you do what you want. However, it does not allow editing of the text, at least not as far as I know.

http://github.com/facebook/three20/blob/master/src/Three20/TTStyledTextLabel.h http://github.com/facebook/three20/blob/master/src/Three20/TTStyledText.h

Hope this helps!

Adrian Kosmaczewski