获取网页高度

// MARK: 代理方法 -- WKWebView

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {

LTLog("页面加载完成")

webView.evaluateJavaScript("document.body.offsetHeight") { (result, error) in

if error == nil {

var newFrame = webView.frame

newFrame.size.height = result as! CGFloat

webView.frame = newFrame

self.headerView.frame = CGRect(x: 0, y: 0, width: ScreenWidth, height: newFrame.size.height)

self.wkView.frame = CGRect(x: 0, y: 0, width: ScreenWidth, height: newFrame.size.height)

LTLog("web高度: \(newFrame.size.height)---headerView高度: \(self.headerView.frame.size.height)")

self.bigTableView.reloadData()

}

}

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容