title: iPhone - UIWebView Gestures
body: <p>I have viewcontrollers set up to track gestures and commit an action, in this case, change the tab. The code for the viewcontrollers is as follows:</p>
  
  <pre><code>#define HORIZ_SWIPE_DRAG_MIN 100
  CGPoint mystartTouchPosition;
  BOOL isProcessingListMove;
  - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  {
      UITouch *touch = [touches anyObject];
      CGPoint newTouchPosition = [touch locationInView:self.view];
      if(mystartTouchPosition.x != newTouchPosition.x || mystartTouchPosition.y != newTouchPosition.y) {
          isProcessingListMove = NO;
      }
      mystartTouchPosition = [touch locationInView:self.view];
      [super touchesBegan:touches withEvent:event];
  }
  
  -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
  {
      UITouch *touch = touches.anyObject;
      CGPoint currentTouchPosition = [touch locationInView:self.view];
  
      // If the swipe tracks correctly.
      double diffx = mystartTouchPosition.x - currentTouchPosition.x + 0.1; // adding 0.1 to avoid division by zero
      double diffy = mystartTouchPosition.y - currentTouchPosition.y + 0.1; // adding 0.1 to avoid division by zero
  
      if(abs(diffx / diffy) &gt; 2.5 &amp;&amp; abs(diffx) &gt; HORIZ_SWIPE_DRAG_MIN)
      {
          // It appears to be a swipe.
          if(isProcessingListMove) {
              // ignore move, we're currently processing the swipe
              return;
          }
  
          if (mystartTouchPosition.x &lt; currentTouchPosition.x) {
              isProcessingListMove = YES;
              self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:0];
              return;
          }
          else {
              isProcessingListMove = YES;
  
              self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:2];
  
              return;
          }
      }
      else if(abs(diffy / diffx) &gt; 1)
      {
          isProcessingListMove = YES;
          [super touchesMoved:touches withEvent:event];
      }
  }
  
  -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
  {
      isProcessingListMove = NO;
      [super touchesEnded:touches withEvent:event];
  }
  </code></pre>
  
  <p>I'd like to have the same gesture do the same thing on a uiwebview I have set up under the view of the viewcontroller. In short, the uiwebview is on the view. When I swipe, I just get the basic uiwebview functions (scrolling). If I set up a custom uiwebview class with the same code as the uiviewcontroller, I get errors. I need to know how to translate that block of code, keeping the functionality intact, to suit the uiwebview.</p>