如何从uiwebview或self.view中检测点击手势? [英] How to detect of tap gesture is from uiwebview or self.view?

查看:114
本文介绍了如何从uiwebview或self.view中检测点击手势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我使用以下代码查看了uitapgesture:

Hello everyone I have a uitapgesture on my view using the following code :

    UITapGestureRecognizer *tap= [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(TAPGestureRecognizer)];
    tap.numberOfTapsRequired=1;
    tap.delegate = self;
    [self.view addGestureRecognizer:tap];

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

我的UIview中有一个uiwebview作为子视图.问题在于在uivewview HTML上它具有onclick();.反过来就是所谓的手势.有帮助吗?

And I have a uiwebview as a subview in my UIview. The problem is that on the uivewview HTML it had a onclick(); which in turn is calling the tapgesture. Any help?

推荐答案

FirstView.image=[UIImage imageNamed:@"shape1.jpg"];
    FirstView.tag=1;
    FirstView.userInteractionEnabled=YES;

    [FirstView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(firstimagetouch:)]];


    SecondWebView.tag=2;
    SecondWebView.userInteractionEnabled=YES;

    [SecondWebView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(firstimagetouch:)]];


-(void)firstimagetouch:(UIGestureRecognizer *)sender
{
    UIView * view=sender.view;

    NSLog(@"%ld",(long)view.tag);
}

尝试这种方式,首先添加手势识别器进行查看,然后根据给他的标签值和获取标签值的web视图.并做你想做的事.

try like this first add gesture recognizer to view and then your webview according to give him tag value and get tag value. and do what you want.

这篇关于如何从uiwebview或self.view中检测点击手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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