- In the webViewDidStartLoad method, I hide the webview.
- Then a request is made.
- In the webViewDidFinishLoad method, I use stringByEvaluatingJavaScriptFromString.
- Finally, the webview is shown again.
However, when I run the app, I can still see how the JavaScript is working. What could be my mistake?
Additionally, I inserted NSLog(@"%@", self.webView) before and after setting self.webView.hidden = FALSE;
<UIWebView: 0x5e37720; frame = (0 44; 768 955); hidden = YES; autoresize = W+H; layer = <CALayer: 0x5e37780>>
<UIWebView: 0x5e37720; frame = (0 44; 768 955); autoresize = W+H; layer = <CALayer: 0x5e37780>>
This is the code from FirstViewController.m :
- (void)webViewDidStartLoad:(UIWebView *)webView{
self.webView.hidden = TRUE;
}
- (void)webViewDidFinishLoad: (UIWebView *) webView {
[self useJScript:self.webView];
NSLog(@"Show %@", self.webView);//result above^^^
self.webView.hidden = FALSE;
NSLog(@"Showned %@", self.webView);
}
- (void)useJScript:(UIWebView *) webView{
NSLog(@"Applying jscript for %@",webView);
NSString *path = [[NSBundle mainBundle] pathForResource:@"jsmain" ofType:@"html"];
NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];
NSString *htmlString = [[NSString alloc] initWithData:[readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];
[webView stringByEvaluatingJavaScriptFromString:htmlString];
}