如何从UIWebview中解析iphone中的richtexteditor的html字符串

时间:2012-02-06 06:22:20

标签: iphone html-parsing richtextediting

我正在使用RichTextEditor完全按照此link详细说明,我需要在按钮单击时在其他类的表视图中显示书面内容,但在表视图单元格中,会出现相应的html字符串。以下是我的代码

-(void)submitClicked{
  contentObject.webCOntent=webView;
            contentObject.savedMessage=SAVED;
            contentObject.str = [webView stringByEvaluatingJavaScriptFromString: 
                         @"document.body.innerHTML"];
            NSLog(@"created  %@",contentObject.str);
}

在tableView cellforRowAyIndexPath中,

cell.textLabel.text = [[notesArray objectAtIndex:indexPath.row]str ];

当我运行应用程序时,它在tableview中显示      Oiuo8

其中,contentObject是modelclass对象,str是字符串,webcontent是模型类中的UIWebView

1 个答案:

答案 0 :(得分:0)

我最终通过更改contentObject.str = [webView stringByEvaluatingJavaScriptFromString获得了解决方案:                          @ “document.body.innerHTML”];至  contentObject.str = [webView stringByEvaluatingJavaScriptFromString:                          @“document.documentElement.textContent”] ;,它给出普通文本而不是html文本。