如何在uiwebview中实现触摸事件? [英] How to implement touch events in uiwebview?

查看:208
本文介绍了如何在uiwebview中实现触摸事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过在本网站和其他人提供的各种解决方案,以在uiwebview上实现触摸事件。但是我仍然无法做到这一点。其实我已经创建了一篇文章阅读器应用程序。在这里,我在普通的uiview上添加了一个uiwebview。现在,我想跟踪一些用户触摸事件在该特定的webview。
当我在普通视图下执行此操作时,它工作得很好。但如果我在webview上尝试。它停止工作。
我以前尝试的解决方案是

I have tried various solutions provided on this site and others to implement touch events on uiwebview. But still I am not able to do this. Actually, i have created a article reader application. Here, I have added a uiwebview on the normal uiview. Now, I want to trace some user touch events on that particular webview. When I do this on normal view, it works perfectly. But if I try it on webview. it stops working. The solutions I tried before are


  1. 实现触摸方式,如
    touchbegan
    touchended
    触摸移动
    触摸取消

2实现uigesturerecognizer
3实现窗口触摸事件,如发送事件

2 implementing uigesturerecognizer 3 implementing window touch events like send event

现在如果有任何人可以帮助我或告诉我我做错了什么或者一个新的解决方案(除了这个),那么我会很感激。

Now If anyone can help me or tell me where I am doing wrong or a new solution(other than this), then I will be thankful.

推荐答案

将透明UIVIew放在您的UIWebView之上以捕获触摸。然后,您可以对其进行操作,或者使用touchesBegan去除方法将其传递给UIWebView。

Put a transparent UIVIew on top of your UIWebView to capture touches. You can then act on them or optionally pass them down to the UIWebView using the touchesBegan deletage method.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [self.myUIWebView touchesBegan:touches withEvent:event];
}

查看上一篇文章了解详情: iOS - 通过视图转发所有内容

Check this previous post for details: iOS - forward all touches through a view

这篇关于如何在uiwebview中实现触摸事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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