How to determine the content size of a UIWebView?

后端 未结 15 1949
灰色年华
灰色年华 2020-11-22 17:06

I have a UIWebView with different (single page) content. I\'d like to find out the CGSize of the content to resize my parent views appropriately. T

15条回答
  •  遇见更好的自我
    2020-11-22 17:43

    Xcode8 swift3.1:

    1. Set webView height to 0 first.
    2. In webViewDidFinishLoad Delegate:

    let height = webView.scrollView.contentSize.height

    Without step1, if webview.height > actual contentHeight, step 2 will return webview.height but not contentsize.height.

提交回复
热议问题