0

如何在 UIWebview 中识别用户touchtap& 。double tap是否有任何可用的代表,例如触摸开始等?

4

2 回答 2

4

这是在 webview 上实现单击和双击的代码

UITapGestureRecognizer *singleTap = [[[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doSingleTap)] autorelease];
singleTap.numberOfTapsRequired = 1; 
[self.myWebView addGestureRecognizer:singleTap];


UITapGestureRecognizer *doubleTap = [[[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doDoubleTap)] autorelease];
doubleTap.numberOfTapsRequired = 2; 
[self.myWebView addGestureRecognizer:doubleTap];
于 2012-07-30T09:46:14.493 回答
0

以下3个链接将解决您的问题

如何将手势识别器添加到 uiwebview 子类

iphone-custom-gestures-on-your-uiwebview

uigesturerecognizer-work-on-a-uiwebview

关于点击次数,可以通过属性numberOfTapsRequired设置

例如:

UITapGestureRecognizer *myGusture = [[[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doTap)] autorelease];
myGusture.numberOfTapsRequired = 1; //you can change it to any number as per your requirement.
[self.myWebView addGestureRecognizer:myGusture];
[myGusture release];
myGusture = nil;
于 2012-07-30T10:03:15.377 回答