开发者

is there anyway to display HTML content in textview?

开发者 https://www.devze.com 2022-12-15 14:32 出处:网络
i tried the following one from iphone cook book .i displayed HTML content through accessing private API of UITextvie开发者_运维技巧w like

i tried the following one from iphone cook book .i displayed HTML content through accessing private API of UITextvie开发者_运维技巧w like

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

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


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;


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!


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


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消