Javascript touchend(滚动)事件在ios 4中的UIWebView中不起作用
Javascript touchend (scroll) event dont work in UIWebView in ios 4
我在UIWebView中使用touchend事件如下:
window.ontouchend=function(touchEvent)
{
...
}
我用它来跟踪UIWebView中的滚动,这个事件通常在iOS 5+中工作,但这个事件在iOS 4中不工作!如何在iOS 4中跟踪javascript中的触摸端事件?
提前感谢您的帮助。
我没有找到在iOS4中使用此JS代码的方法所以我决定把这个代码留给iOS 5,但对于早期的iOS版本,我是从这个问题中做出决定的:如何拦截MKMapView或UIWebView对象上的触摸事件?
在我的viewController中,我写下了以下代码:
NSString *sysVersion=[[UIDevice currentDevice] systemVersion];
NSArray *sysVersionParse=[sysVersion componentsSeparatedByString:@"."];
int versionNum=[[sysVersionParse objectAtIndex:0] intValue]; //detect ios version
if (versionNum<5)
{
WildcardGestureRecognizer * tapInterceptor = [[WildcardGestureRecognizer alloc] init];
tapInterceptor.touchesEndCallback = ^(NSSet * touches, UIEvent * event)
{
NSString *jsString = [[NSString alloc] initWithFormat:@"window.ontouchend();"];
[webview stringByEvaluatingJavaScriptFromString:jsString];
};
//and similarly for the other touch actions
[webview addGestureRecognizer:tapInterceptor];
}
我希望有人得心应手!
相关文章:
- Javascript窗口.open中的UTF8字符串将被UIWebview's应该启动LoadWithReque
- Javascript touchend(滚动)事件在ios 4中的UIWebView中不起作用
- UIWebView中的点击事件不会'不起作用
- objective-C 在 UIWebView 中的 ajax 调用后获取 HTML 值
- I'我正在尝试将JavaScript加载到我的UIWebView中
- 我可以使用window.postMessage方法从iframe中的网页通信到包括该iframe的UIWebView吗
- 更改UIWebView中的文本字体大小-如何设置textFontSize的初始值
- 我可以在单独的线程中运行 UIWebView 吗?
- 通过 Swift 中的 UIWebView 从 Javascript 传递数组
- 如何在 IOS 上的 UIWebview 中拦截按钮单击
- 突出显示 UIWebView 中的文本
- 以编程方式单击 UIWebView 中的“提交”按钮(无元素 ID、名称、类或标记)
- 在 iOS 7+ 的 UIWebView 中使用语音合成 API 设置速率、音高、音量
- 突出显示表视图单元格中的 uiwebview 文本
- 单击具有 UIButton 的 UIWebView 中的锚点
- 在ios7的UIWebView中禁用js警报
- 恢复 UIWebView 中的位置
- 更改UIWebView中的字体大小
- Swift正在等待从UIWebView中的javascript加载页面
- 如何在Swift中的UIWebView中获取JS值