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 的内容高度?


基础教程推荐
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01