How to get the content height of a UIWebView in iPhone sdk, objective-c?(如何在 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 的内容高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 iPhone sdk,objective-c 中获取 UIWebView 的内容高度?
基础教程推荐
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
