在我的应用程序中,我有一个带有详细视图的表格视图。详细视图从HERE加载博客文章,详细视图将显示该文章中的文本。我几乎让它工作了,但我仍然需要弄清楚如何修复文本(下面的示例)。这是我必须在详细视图中从网站中提取文本的代码:
-(void)viewDidLoad {
//self.url is from the table view where the link to the website is
NSURL *myURL = [NSURL URLWithString: [self.url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
NSURLRequest *request = [NSURLRequest requestWithURL:myURL];
[self.webView loadRequest:request];
timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(LoadText) userInfo:nil repeats:YES];
}
-(void)webViewDidLoadText {
NSString *textForBlog = [self.webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('paragraph')[0].innerHTML;"];
self.textView.text = textForBlog;
}