如何在UIWebView上创建Tap事件?

时间:2022-09-06 21:04:28

I have added Long Tap gesture on UIWebView. But I want UIWebView to process a standard Tap event before my Long Tap will be recognized. (Two gestures should be processed on Long Tap - a simple Tap and my Long Tap). How to do this?

我在UIWebView上添加了长点击手势。但是我希望UIWebView在我的长点击被识别之前处理一个标准的Tap事件。(两种手势应该在长丝锥上处理——一个简单的水龙头和我的长丝锥)。如何做到这一点呢?

I think it's required to send Tap event to UIWebView on TouchBegin. Is it correct?

我认为需要在TouchBegin上向UIWebView发送Tap事件。是正确的吗?

2 个解决方案

#1


2  

The correct code:

正确的代码:

- (void)viewDidLoad {
    UILongPressGestureRecognizer* gesture = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)] autorelease];
    gesture.delegate = self;
    [myWebView addGestureRecognizer:gesture];
}

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

#2


1  

Please refer this section UIGestureRecognizerDelegate

请参阅本节UIGestureRecognizerDelegate

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIGestureRecognizerDelegate_Protocol/Reference/Reference.html

http://developer.apple.com/library/ios/文档/ uikit /引用/ UIGestureRecognizerDelegate_Protocol /引用/ Reference.html

you found this is called when 2 gesture simultaneous work.

当两个手势同时进行时,你会发现这被称为手势。

gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:

手势识别器:shouldRecognizeSimultaneouslyWithGestureRecognizer:

#1


2  

The correct code:

正确的代码:

- (void)viewDidLoad {
    UILongPressGestureRecognizer* gesture = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)] autorelease];
    gesture.delegate = self;
    [myWebView addGestureRecognizer:gesture];
}

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

#2


1  

Please refer this section UIGestureRecognizerDelegate

请参阅本节UIGestureRecognizerDelegate

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIGestureRecognizerDelegate_Protocol/Reference/Reference.html

http://developer.apple.com/library/ios/文档/ uikit /引用/ UIGestureRecognizerDelegate_Protocol /引用/ Reference.html

you found this is called when 2 gesture simultaneous work.

当两个手势同时进行时,你会发现这被称为手势。

gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:

手势识别器:shouldRecognizeSimultaneouslyWithGestureRecognizer: