The Red box section is Wkwebview, the left side is the normal display, the right side of the exception display.
I am the webview highly adaptable content executed in the Web page load completion callback:
// 页面加载完成之后调用- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{ if ([webView isFinishLoading] == YES) { self.webView.height = self.webView.scrollView.contentSize.height;
Both sides get the same height, but the right is not fully displayed, but also magnified.
What makes me crazy is that sometimes loading is complete and sometimes incomplete.
What makes me crazy is that if I write a deferred load delay of one second, this time the display is all right:
// 页面加载完成之后调用- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{ if ([webView isFinishLoading] == YES) { __weak typeof(self) weakSelf = self; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // 1秒后异步执行这里的代码... weakSelf.webView.height = weakSelf.webView.scrollView.contentSize.height;
If I use UIWebView instead of Wkwebview, I will not encounter this problem.
Who can tell me why the page is sometimes not fully displayed ... Thank you first.
iOS-why load the same HTML text with Wkwebview, and sometimes show something different.