3

我在 上添加了长按手势UIWebView。但我想UIWebView在我的 Long Tap 被识别之前处理一个标准的 Tap 事件。(Long Tap 应该处理两个手势——一个简单的 Tap 和我的 Long Tap)。这个怎么做?

我认为需要将 Tap 事件发送到UIWebViewon TouchBegin。这是对的吗?

4

2 回答 2

2

正确的代码:

- (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;
}
于 2012-11-09T14:23:11.110 回答
1

请参考本节 UIGestureRecognizerDelegate

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

你发现这在 2 个手势同时工作时被调用。

gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:

于 2012-11-07T04:45:56.320 回答