How to determine the content size of a UIWebView?

后端 未结 15 2130
灰色年华
灰色年华 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:45

    When using webview as a subview somewhere in scrollview, you can set height constraint to some constant value and later make outlet from it and use it like:

    - (void)webViewDidFinishLoad:(UIWebView *)webView {
        webView.scrollView.scrollEnabled = NO;
        _webViewHeight.constant = webView.scrollView.contentSize.height;
    }
    

提交回复
热议问题