UIWebView中的ScrollOffset? [英] ScrollOffset in UIWebView?

查看:74
本文介绍了UIWebView中的ScrollOffset?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很难理解代理和对象继承(如果我可以使用这个词),我想我需要一个简单的(或所以我认为)事情:在UIWebView中捕获scrollViewDidScroll事件和获得偏移(基本上,只是为了知道滚动不是在顶部/底部,所以我可以隐藏导航和标签栏)。

I'm having a really hard time understanding delegates and object inheritance (if I may use this word) and I think I need a simple (or so I think) thing: catch scrollViewDidScroll event in UIWebView and get offset (basically, just to know if scroll is not on top/bottom, so I could hide navigation and tab bars).

有什么办法吗?我已经在我的视图控制器中使用UIWebviewDelegateshouldStartLoadWithRequest。也许我可以一些如何使用UIScrollViewDelegate也为scrollViewDidScroll?如果是,那么如何?

Is there any way I could do it? I already using UIWebviewDelegate in my view controller to "shouldStartLoadWithRequest". Maybe I could some how use UIScrollViewDelegate too for scrollViewDidScroll? If yes, then how?

我真的很难理解代表。

I really have trouble understanding delegates. I've red some articles, but still, in practice, I can't manage to use them.

任何帮助或信息都很可爱。

Any help or info would be lovely.

提前谢谢!

推荐答案

$ c> UIWebView ,但它a)不是一个 UIScrollView ,b)苹果认为一个私人实现细节太)。我只有两个建议:

There is a scrolling view in the UIWebView, but it a) isn't a UIScrollView, and b) is something Apple considers a private implementation detail (and you should too). I only really have two suggestions:


  1. 向苹果提出一个错误,要求他们展示更多的网络视图基础设施,添加一些委托方法,通知我们可以通知这些类型的事件。

  2. 添加一些JavaScript代码到您的页面,监听滚动事件,并通知您的应用程序。 li>
  1. File a bug with Apple asking them to expose more of the infrastructure of the web view, or at least add some more delegate methods by which we can be notified of these sorts of events.
  2. Add some JavaScript code to your page that listens from scroll events, and notifies your app of them.

#2的基本基础是加载一个假URL,并加载您的Web视图委托进程(和abort!)。 (这个问题在Stack Overflow上已经出现了几次。)

The basic foundation of #2 is to load a fake URL, and have your web view delegate process (and abort!) that load. (This question has come up a few times here on Stack Overflow.)

UPDATE:

从iOS 5起,现在有一个 a>,您可以使用它来自定义滚动行为。网络视图的确切视图层次结构仍然是未记录的实施细节,但这给了您访问这一块的一个受制裁的方式。

As of iOS 5, there is now a public scrollView property on UIWebView that you can use to customize scrolling behavior. The exact view hierarchy of the web view remains an undocumented implementation detail, but this gives you a sanctioned way to access this piece of it.

这篇关于UIWebView中的ScrollOffset?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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