Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing touch info to UIScrollView under another UIView

I have a UIScrollView under a transparant UIView. I need to transfer all pans and taps to the scroll view (which only scrolls horizontally). The regular UIView uses a subclass of UIPanGestureRecognizer to track vertical pans (Subclass found here). In the overlay view, I override the touch event methods to pass them to the UIScrollView.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
    [self.scrollView.panGestureRecognizer touchesBegan:touches withEvent:event];
    [self.scrollView.singleTapGesture touchesBegan:touches withEvent:event];
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesCancelled:touches withEvent:event];
    [self.scrollView.panGestureRecognizer touchesCancelled:touches withEvent:event];
    [self.scrollView.singleTapGesture touchesCancelled:touches withEvent:event];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesEnded:touches withEvent:event];
    [self.scrollView.panGestureRecognizer touchesEnded:touches withEvent:event];
    [self.scrollView.singleTapGesture touchesEnded:touches withEvent:event];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesMoved:touches withEvent:event];
    [self.scrollView.panGestureRecognizer touchesMoved:touches withEvent:event];
    [self.scrollView.singleTapGesture touchesMoved:touches withEvent:event];
}

The overlay view, the vertical pan works perfectly. In the UIScrollView, the taps also work perfectly. The scrolling though, not so much. The scroll view scrolls about three points, then stops (as I continue with the horizontal pan.) If I let go with a velocity, the scroll view then picks up that velocity and finishes scrolling.

What would be the possible issues causing the scroll view to stop scrolling then pick up the velocity?

like image 382
Brandon Mcq Avatar asked Jan 05 '13 22:01

Brandon Mcq


1 Answers

From the code you posted, I assume you are not doing anything with the transparent UIView.. then why don't you just set userInteractionEnabled = NO; ??

like image 128
chuthan20 Avatar answered Nov 08 '22 17:11

chuthan20