如何在 iPhone sdk,objective-c 中获取 UIWebView 的内容高度? [英] How to get the content height of a UIWebView in iPhone sdk, objective-c?

查看:17
本文介绍了如何在 iPhone sdk,objective-c 中获取 UIWebView 的内容高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何确定 UIWebView 的内容大小?

大家好,

我在将 htmlString 加载到 UIWebView 时遇到问题,我在 iphone 中将 webview 的框架高度设置为始终为 265.

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)];

是否有任何属性可以获取 UIWebView 的内容高度.

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.

谢谢你,马丹·莫汉.

推荐答案

试试这个:

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

在您的 webViewDidFinishLoad 方法中.

这篇关于如何在 iPhone sdk,objective-c 中获取 UIWebView 的内容高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆