简体   繁体   English

在iOS中使用滚动编程时的Javascript滚动事件

[英]Javascript scroll event when scroll was programmatic in iOS

I have an iOS app that involves a UIWebView. 我有一个涉及UIWebView的iOS应用。 There is javascript in the web view that reacts to scroll events. 网络视图中有javascript可以响应滚动事件。 There is a way to make the web view scroll by tapping on one side or the other of the web view. 有一种方法可以通过点击Web视图的一侧或另一侧来使Web视图滚动。 The problem is that the javascript in the web view does not seem to pick up the scroll event when the scroll was done programmatically. 问题在于,以编程方式完成滚动时,Web视图中的javascript似乎没有拾取滚动事件。

This is the code I use to scroll the web view: 这是我用来滚动Web视图的代码:

[self.webView.scrollView setContentOffset:CGPointMake(targetX, y);

Is there a different way to do this so that the javascript reacts to the scroll? 有没有其他方法可以做到这一点,以便javascript对滚动做出反应? Or am I going to have to run javascript on the web view programmatically when the scroll event finishes? 还是在滚动事件结束时必须在网络视图上以编程方式运行javascript?

您是否尝试过:

[self.webView.scrollView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM