如何通过“下拉并释放”刷新 UIWebView手势?
我知道这在 iPhone 版 Tweetie 或 xkcd iPhone 应用程序中是可能的,但他们使用的是表格。您知道这是否也可以用于简单的 UIWebView 吗?我知道这个SO问题中的Javascript建议,但是如何在本地制作它呢?
I know that this is possible in the Tweetie for iPhone or the xkcd iPhone app, but they are using a table. Any idea if this can be done for a simple UIWebView
as well? I'm aware of the Javascript suggestions in this SO question, but what about making that natively?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要检索 UIWebView 上的滚动事件,我个人使用此代码来获取 UIWebView 内的滚动视图:
它正在工作。您还可以使用它来调用
[(UIScrollView*)subView setContentOffset:offSetanimated:YES];
唯一的问题可能是没有通过 Apple 代码检查。我还不知道,因为我仍处于编码阶段。有人尝试过吗?
To retrieve scroll events on UIWebView I personnaly use this code to get the scrollview that is inside the UIWebView :
It's working. You can also use it to call
[(UIScrollView*)subView setContentOffset:offSet animated:YES];
The only problem may be not to pass Apple code checking. I don't know yet since I'm still in coding phase.Anyone tried that yet ?
仅供参考,iOS 5 正式在 UIWebView 中引入了 scrollView 属性。我测试过。它与 EGO 的拉取和刷新代码完美配合。所以这个问题对于任何 iOS 5 设备来说都不再是问题。
为了向下兼容,您仍然需要 @CedricSoubrie 的代码。
FYI, iOS 5 has officially introduced the property scrollView in UIWebView. I tested it. It worked perfectly with EGO's pull and refresh code. So the problem is no longer a problem for any iOS 5 devices.
For downward compatibility, you still need @CedricSoubrie's code though.
说实话,UIWebVIew 类有一个未记录的 getter 方法,称为 _scrollView;
所以代码如下:
scrollView = [webView _scrollView];
To tell the truth, UIWebVIew class has an undocumented getter method called _scrollView;
So the code goes:
scrollView = [webView _scrollView];
要获取 UIWebView 中 UIScrollView 的引用,只需通过迭代子视图来搜索它即可。
之后,您可以使用 UIWebView 和 UIScrollView 委托回调轻松地将事物连接到 EGORefreshTableHeaderView 界面。
To get a reference for the UIScrollView in UIWebView, simply search it by iterating trough subviews.
After that you can easily wire up things to your EGORefreshTableHeaderView interface with the UIWebView and the UIScrollView delegate callbacks.