3

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?

4 Answers4

3

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;
samvermette
  • 40,269
  • 27
  • 112
  • 144
1

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.

Hope this helps!

Atulkumar V. Jain
  • 5,102
  • 9
  • 44
  • 61
Adrian Kosmaczewski
  • 7,956
  • 4
  • 33
  • 59
0

If you want HTML, your best bet is to use a dedicated UIWebView.

sgonzalez
  • 1,086
  • 9
  • 24
0

You can try this one.This is uses core text framework

https://github.com/aryaxt/iOS-Rich-Text-Editor

Nagendra Tripathi
  • 923
  • 12
  • 23