How to get the content height of a UIWebView in iPhone sdk, objective-c? [duplicate]

巧了我就是萌 提交于 2019-11-29 04:01:11

问题


Possible Duplicate:
How to determine the content size of a UIWebView?

Hai Guys,

I got a problem while lodaing the htmlString into UIWebView, I have set the frame height of a webview in iphone is 265 always.

    webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 41, 320, 265)];

Is there any property to get content height of a UIWebView.

If I got the content only one or two lines then it is looking odd below the two lines. How can I make it dynamic. Please suggest any solution.

Thank you, Madan Mohan.


回答1:


try this:

[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"]

in your webViewDidFinishLoad method.



来源:https://stackoverflow.com/questions/3837214/how-to-get-the-content-height-of-a-uiwebview-in-iphone-sdk-objective-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!