iOS-why load the same HTML text with Wkwebview, sometimes showing different content.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.