无法发出服务信号com.apple.WebKit.WebContent:113:找不到指定的服务
当我尝试在WKWebView中加载HTML时,我会在iOS中定期收到此消息。当我打开WKWebView页面时,它也在重复。
WKWebViewConfiguration *conf = [[WKWebViewConfiguration alloc] init];
_articleWebView = [[WKWebView alloc] initWithFrame:_mainView.containterViiew.bounds configuration:conf];
_articleWebView.navigationDelegate = self;
_articleWebView.scrollView.scrollEnabled = NO;
[_mainView.containterViiew addSubview:_articleWebView];
[_articleWebView loadHTMLString:_articleDesc.pageContent baseURL:nil];
我也试图在完成方法中获取WKWebView的内容高度。发生上述错误时,我得到不同的高度值。
- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation {
[webView evaluateJavaScript:@"document.readyState"
completionHandler:^(id complete, NSError * _Nullable error) {
if (complete != nil) {
NSString *javascriptString = @"var body = document.body;var html = document.documentElement;Math.max(html.offsetHeight);";
[webView evaluateJavaScript:javascriptString
completionHandler:^(id _Nullable result, NSError * _Nullable error) {
if (!error) {
NSNumber *height = result;
NSLog(@"height ----------->>>%@", height);
});
}
}];
}