self.nflWebView = [[WKWebView alloc] initWithFrame:self.view.bounds];
self.nflWebView.backgroundColor = [UIColor clearColor];
self.nflWebView.opaque = NO;
[[self nflWebView] setDelegateViews: self];
self.nflWebView.tag = 10000;
[self.nflWebView loadHTMLString:html baseURL:[NSBundle mainBundle].bundleURL];
[self.view addSubview:self.nflWebView];
I have also try the another things:
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
{
NSLog(@"stringByEvaluatingJavaScriptFromString");
NSLog(@"script :%@",script);
__block NSString *resultString = nil;
__block BOOL finished = NO;
WKWebView *obj_wkwebview=[[WKWebView alloc]init];
[obj_wkwebview evaluateJavaScript:script completionHandler:^(id result, NSError *error) {
if (error == nil) {
if (result != nil) {
resultString = [NSString stringWithFormat:@"%@", result];
}
} else {
NSLog(@"evaluateJavaScript error : %@", error);
}
finished = YES;
}];
while (!finished)
{
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
return resultString;
}
its give the error.
Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo=0x170c788c0 {NSLocalizedDescription=A JavaScript exception occurred}
simple html content is loading successfull but html with javascript is not loading.
I have done a lot of Googling but not success. Please Suggest me if u have any another approach to do this thing. Thanks in advance.