WKWebViewTips icon indicating copy to clipboard operation
WKWebViewTips copied to clipboard

Height

Open LiYang-Young opened this issue 9 years ago • 4 comments

hi:

How to get the WKWebview's realHeight after finishLoad?? please help...

LiYang-Young avatar Oct 19 '16 00:10 LiYang-Young

The following code must do the job:

[webView evaluateJavaScript:@"document.body.scrollHeight" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
        NSNumber *scrollHeight = result; 
    }];

gixdev avatar Oct 19 '16 10:10 gixdev

I have a question,i put the WKWebView in the UITableView's Cell, I hope the cell can the same height with webView, so,they can scroll together.so i by [webView evaluateJavaScript:@"document.body.scrollHeight" completionHandler:^(id _Nullable result, NSError * _Nullable error) { NSNumber *scrollHeight = result; }]; get the webview's real height , and make the cell the same height with webView, but the webView can not show complete,,I do not the reason,,,,please help me

LiYang-Young avatar Oct 20 '16 07:10 LiYang-Young

I use webView.scrollView.contentSize.height instead of the JavaScript code.

ShingoFukuyama avatar Oct 20 '16 13:10 ShingoFukuyama

Actually webView.scrollView.contentSize.height work not well below iOS9. Especially this page still don't finish load. In this case, you get a wrong result. After webview finish load page, you maybe get a another wrong result when user touch the page. @ShingoFukuyama

NikoXu avatar Dec 23 '16 04:12 NikoXu