0
votes

I'm writing an iPad app in which I make intense use of a UIWebView inside a UIViewController.

I'm tying a few actions to swipe gesture recognizers. They detect both left and right swipes. Since my web view scrolls up and down, it is very easy to try a horizontal swipe and get the webview to scroll up or down a bit, what ends up failing the gesture recognizer.

So is there any way to avoid this behavior? Maybe to detect the start of the horizontal swipe and lock the UIWebView vertical position?

Thanks!

1

1 Answers

0
votes

You could intercept the continueTrackingWithTouch:withEvent call and selectively return NO - or perhaps even cancel the swipe.

E.g. something like

(BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
{
    if (... too diagonal to my taste) .. 
          return (NO);
    return [super continueTrackingWithTouch:touch withEvent:event];
}

where 'too diagonal' could be as simple as checking if the begin spot & current spot are too non-ortogonal (e.g. dx = firstX - lastX, dy = firstY - lastY; len2 = dx * dx + dy * dy - which is only allowed some ratio relative to area = dx * dy.

Thanks,

Dw.