Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIscrollView DidScroll - only when touches

I want to detect when user is scrolling a UIScrollView. scrollViewDidScroll is called when that happens, but it's called also in another time - when the user scrolls the view out of bounds, and then releases, the view jump back to it's place - and the method is called even though the user doesn't touch the screen at all (the view is scrolled by itself).

how can I detect scrolling and user touch together?

like image 202
Amit Hagin Avatar asked Apr 30 '12 09:04

Amit Hagin


1 Answers

UIScrollView has a property dragging that indicates whether the scrolling was done by the user. So to see whether the user scrolls the scrollview or the scrolling is caused by something other (like an animation) you can do the following:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
   if (scrollView.dragging) {
      // scrolling is caused by user
   }
}
like image 130
joern Avatar answered Nov 09 '22 03:11

joern