Merge branch 'bugfix/webView_scrollView_contentsize_2' into 'release/8_0_0'
fix See merge request BPHV_MIPS/mvm_core_ui!572
This commit is contained in:
commit
aed3f6b4cf
@ -129,30 +129,29 @@ extension WebView : WKUIDelegate {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
//TODO: Check and remove the comment
|
|
||||||
was using "document.readyState" to check the state,
|
was using "document.readyState" to check the state,
|
||||||
while evaluateJavaScript "document.readyState",only works when webview contains userscrpt.otherwise, it would return WKErrorDomain Code=4 "A JavaScript exception occurred".
|
while evaluateJavaScript "document.readyState",only works when webview contains userscrpt.otherwise, it would return WKErrorDomain Code=4 "A JavaScript exception occurred".
|
||||||
so webView.isLoading to check load finished state
|
so webView.isLoading to check load finished state
|
||||||
*/
|
*/
|
||||||
webView.evaluateJavaScript("document.readyState", completionHandler: { (complete, error) in
|
if !webView.isLoading {
|
||||||
if complete == nil {
|
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
|
||||||
return
|
guard let self = self else {
|
||||||
}
|
return
|
||||||
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
|
}
|
||||||
guard let self = self else {
|
MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in
|
||||||
return
|
guard let self = self else {
|
||||||
}
|
return
|
||||||
let scrollHeight = self.webView?.scrollView.contentSize.height ?? 44.0
|
}
|
||||||
if let height = result as? CGFloat,
|
if let height = result as? CGFloat {
|
||||||
height < scrollHeight {
|
self.webViewHeight?.constant = height
|
||||||
self.webViewHeight?.constant = height
|
} else {
|
||||||
} else {
|
//if failed to get height from javascript, using scrollview.contensize's height
|
||||||
//if failed to get height from javascript, using scrollview.contensize's height
|
self.webViewHeight?.constant = webView.scrollView.contentSize.height
|
||||||
self.webViewHeight?.constant = scrollHeight
|
}
|
||||||
}
|
self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
|
||||||
self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
|
})
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user