UITableViewCell With UIWebView Dynamic Height

前端 未结 10 2086
深忆病人
深忆病人 2020-12-04 11:52

I have a table view with cells that have a webView in them, I want the height of the cell to match the height of the webView.

This is the code I use:



        
10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-04 12:21

    I have one more solution that you should consider. Make a height constraint and link it to your UITableViewCell class. Then implement the delegate method func webViewDidFinishLoad(_ webView: UIWebView), and when it is called set the height constraint to be equal to webView.scrollView.contentSize.height.

提交回复
热议问题