iPhone: How to Display Text from UIWebView HTML Document in a UITextView

Posted by ArgMan on Stack Overflow See other posts from Stack Overflow or by ArgMan
Published on 2010-03-15T10:32:10Z Indexed on 2010/04/12 0:13 UTC
Read the original article Hit count: 1146

Filed under:
|
|
|

I have an RSS feed that gets arranged in a UITableView which lets the user select a story that loads in a UIWebView. However, I'd like to stop using the UIWebView and just use a UITextView or UILabel.

This png is what I am trying to do (just display the various text aspects of a news story):

alt text

I have tried using:

NSString *myText = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.textContent"];

and assigning the string to a UILabel but it doesn't work from where I am implementing it in webViewDidFinishLoad (--is that not the proper place?). I get a blank textView and normal webView.

If I overlay a UITextView on top of a UIWebView on its own (that is, a webView that just loads one page), the code posted above works displays the text fine. The problem arises when I try to process the RSS feed .

I've been stuck wondering why this doesn't work as it should for a few days now. If you have a better, more efficient way of doing it then placing the code in webViewDidFinishLoad, please let me know! Does it go in my didSelectRowAtIndexPath?

Thank you very much in advance!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about rss