I am trying to load a webpage in a WKWebView control without loading it as a preview:
WKPreferences *preferences = [[WKPreferences alloc] init]; preferences.javaScriptEnabled = YES; WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init]; configuration.preferences = preferences; WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration]; webView.navigationDelegate = self; NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url]; [urlRequest setValue:@"Safari" forHTTPHeaderField:@"User-agent"]; [webView loadRequest:urlRequest];
I am trying to download the url:
https:
The following WKNavigationDelegate method WKNavigationDelegate not called:
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation { [webView evaluateJavaScript:@"document.getElementsByTagName('html')[0].outerHTML" completionHandler:^(id result, NSError *error) { NSLog(@"Result %@", result); }]; }
My NSObject class conforms to the WKNavigationDelegate protocol.
Do I need to do something?
Feel any help.
source share