Intercept UITableView scroll touches

Posted by Jonesy on Stack Overflow See other posts from Stack Overflow or by Jonesy
Published on 2010-06-03T20:53:22Z Indexed on 2010/06/03 21:14 UTC
Read the original article Hit count: 587

Is it possible to control when the UITableView scrolls in my own code.

I am trying to get behaviour where a vertical swipe scrolls and a horizontal swipe gets passed through to my code (of which there are many example)

BUT

I want a DIAGONAL swipe to do nothing, i.e the UITableView should not even begin scrolling.

I tried catching it in here

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

but the scrollView.contentOffset.x is always 0 so I cannot detect a horizontal movement.

I also tried subclassing UITableView and implementing

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

etc..

but the UITableView (and I guess it's parent UIScrollView) start to scroll before the touches are notified?

To re-iterate, I want the UITableView scrolling to be locked if a diagonal swipe is made, but to scroll vertically normally.

(This behaviour can be seen in Tweetie(Twitter) for the iPhone)

Thanks for any help!

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about uitableview