Question

the problem is the following: I'm trying to get a table from html using "stringByEvaluatingJavaScriptFromString". The table itself is pulled in NSLog, but she does not want to appear in the UIWebView. Here is my code:

- (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];
}

I think this page should be updated somehow, but I do not know how ((

Help please!

Was it helpful?

Solution

This might be a simple variable mis-naming error.

I see:

- (void)webViewDidFinishLoad:(UIWebView*)webView1

while you're referring to everything within that function as "webView" (without the "1").

Also, make certain that your "webView" is not NULL and that it's what you're expecting it to be, since you're attempting to load it with the (apparently correctly parsed) "html1" code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top