如何在 UIWebView 中设置内容偏移量和内容大小

2023-10-22移动开发问题
3

本文介绍了如何在 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:

  1. 创建一个UIWebView
  2. 把它放在一个UIScrollView
  3. 使用loadHTMLString"将 HTML 添加到其中
  4. 使用- (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 中设置内容偏移量和内容大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

如何将 32 位 PNG 转换为 RGB565?
How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)...
2024-08-12 移动开发问题
21

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7