问题如下:我正在尝试使用“stringByEvaluatingJavaScriptFromString”从 html 中获取一个表。表本身在 NSLog 中被拉取,但她不想出现在 UIWebView 中。这是我的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
filePath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0],@"index.html"];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:filePath]]];
}
- (void)webViewDidFinishLoad:(UIWebView*)webView1
{
NSLog(@"webViewDidFinishLoad");
html = [webView stringByEvaluatingJavaScriptFromString: @"document.body.getElementsByClassName('bottomwideborder')[1].innerHTML;"];
html1 = [NSString stringWithFormat:@"<html><body>%@</body></html>", html];
[webView loadHTMLString:html1 baseURL:[NSURL URLWithString:filePath]]; //Here page does not refresh
NSLog(@"%@", html1); //It's all displayed
[webView stopLoading];
}
我认为这个页面应该以某种方式更新,但我不知道如何((
请帮忙!