How to determine the content size of a UIWebView?

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

    A simple solution would be to just use webView.scrollView.contentSize but I don't know if this works with JavaScript. If there is no JavaScript used this works for sure:

    - (void)webViewDidFinishLoad:(UIWebView *)aWebView {
        CGSize contentSize = aWebView.scrollView.contentSize;
        NSLog(@"webView contentSize: %@", NSStringFromCGSize(contentSize));
    }
    

提交回复
热议问题