在tableview的自定义cell里,放了一个webview,用来加载一段html代码,怎么去计算cell的高度呢。

解决方案 »

  1.   

    webview的高度是应该固定的,显示的html如果超过webview的高度可以滚屏显示。如果是想html的高度是多高,webview就多高,那你应该问的是这个问题.如果是,可以参考:http://stackoverflow.com/questions/7341767/ios-resize-uiwebview-to-fit-content
      

  2.   

    CGFloat webViewHeight = [[self.webCell.webView stringByEvaluatingJavaScriptFromString: @"document.body.scrollHeight"] intValue];
            return webViewHeight;
    楼上正解
      

  3.   

    终极解决方案:http://blog.zlcode.com/2016/04/28/ios-webview-cell/