原文地址:http://justinimhoff.com/swipe-gesture-with-uiwebview/

This is something that had me  banging my head against the wall and thought I would share. The use case is using the left and right swipe gesture to register against the UIWebView/UIView that then calls a swipe function. For my case I was using it to change navigation on a UITableView, but you could use is for back/forward on the UIWebView itself or use the same process to register custom gestures. Of all the resources I found, they use a UIView over the UIWebView, or a disable interactivity on the UIWebView and then push touch event into it. The code is used inside a UIViewController with a UIWebVIew present.

- (void)viewDidLoad
{
     [super viewDidLoad];
     UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeRightAction:)];
     swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
     swipeRight.delegate = self;
     [webView addGestureRecognizer:swipeRight];
 
     UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)];
     swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
     swipeLeft.delegate = self;
     [webView addGestureRecognizer:swipeLeft];
}
 
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
     return YES;
}
 
- (void)swipeRightAction:(id)ignored
{
     NSLog(@"Swipe Right");
     //add Function
}
 
- (void)swipeLeftAction:(id)ignored
{
     NSLog(@"Swipe Left");
     //add Function
}