How to set content offset and content size in a UIWebView(如何在 UIWebView 中设置内容偏移量和内容大小)
问题描述
由于格式原因,我不得不将 UIScrollView 更改为 UIWebView.
I have had to change a UIScrollView into a UIWebView due to formatting reasons.
虽然我需要能够将内容偏移量返回到 0, 0 有一个问题(因为我正在使用可重用的 UIWebViews 并更改内容)并获取内容大小,以便我可以在底部放置一个按钮;但是UIWebView好像没有这个.
There is a problem though that I need to be able to get the content offset back to 0, 0 (as I am using reusable UIWebViews and changing content) and get the content size so I can place a button at the bottom; but UIWebView does not seem to have this.
推荐答案
我发现解决问题的最佳方法是:
The best way I found to sort the problem was:
- 创建一个
UIWebView - 把它放在一个
UIScrollView - 使用loadHTMLString"将 HTML 添加到其中
使用- (void)webViewDidFinishLoad:(UIWebView *)webView {"委托方法检测
UIWebView的大小
将UIWebView的frame设置为内容大小.
Set the frame of the UIWebView to the content size.
然后使用 UIScrollView 的功能而不是 UIWebView.
Then used the functionality of the UIScrollView instead of the UIWebView.
谢谢-JM
这篇关于如何在 UIWebView 中设置内容偏移量和内容大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 UIWebView 中设置内容偏移量和内容大小
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iOS4 创建后台定时器 2022-01-01
