is there anyway to display HTML content in textview?

前端 未结 4 638
借酒劲吻你
借酒劲吻你 2021-01-14 12:14

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

 @interface UITextView (extended)
         


        
相关标签:
4条回答
  • 2021-01-14 12:57

    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;
    
    0 讨论(0)
  • 2021-01-14 12:59

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

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

    0 讨论(0)
  • 2021-01-14 13:10

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

    0 讨论(0)
  • 2021-01-14 13:12

    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!

    0 讨论(0)
提交回复
热议问题