如何在UIWebView中设置内容偏移量和内容大小 [英] How to set content offset and content size in a UIWebView

查看:325
本文介绍了如何在UIWebView中设置内容偏移量和内容大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于格式原因,我不得不将 UIScrollView 更改为 UIWebView

I have had to change a UIScrollView into a UIWebView due to formatting reasons.

虽然我需要能够将内容偏移量恢复到 0,0 (因为我使用的是可重用的 UIWebView s和更改内容)并获取内容大小,以便我可以在底部放置一个按钮;但是 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
  4. $将HTML添加到其中b $ b
  5. 使用 - (void)webViewDidFinishLoad:(UIWebView *)webView {委托方法我检测 UIWebView的大小

  1. Create a UIWebView
  2. Put it in a UIScrollView
  3. Add the HTML into it using "loadHTMLString"
  4. Using the "- (void)webViewDidFinishLoad:(UIWebView *)webView {" delegate method I detect the size of the UIWebView

UIWebView 的框架设置为内容大小。

Set the frame of the UIWebView to the content size.

然后使用<$的功能c $ c> UIScrollView 而不是 UIWebView

谢谢
-JM

Thanks -JM

这篇关于如何在UIWebView中设置内容偏移量和内容大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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