How to detect double taps in UIWebView
You can use this robust approach, or this smart method. But the first is using the UNDOCUMENTED (private) API, and the second is not working for me (and for somebody according to the comments on that blog post). So this is my solution.
Subclass UIWebView and put these lines under your implementation:
- (UIView *)hitTest:(CGPoint)point
withEvent:(UIEvent *)event
{
CGPoint p = currentPoint;
NSTimeInterval t = currentTimestamp;
currentPoint = point;
currentTimestamp = [event timestamp];
if (CGPointEqualToPoint(p, point) &&
[event timestamp] - t < 0.2){
NSLog(@"double taps");
return self.superview;
}
return [super hitTest:point withEvent:event];
}
Notice: declare ivar currentPoint and currentPoint in your header file.
It works like a charm.
September 24th, 2009 at 17:32
呃。。。。。英文不好的说,你应该全部翻译出来!:)
November 17th, 2009 at 19:20
小僧cclv特来拜访
rz