5
votes

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?

2

2 Answers

12
votes

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
   }
}
0
votes

For Swift 5

func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if scrollView.isDragging {
            print("Scroll View is scrolled by the user!")
        }
    }

Also make sure to assign the scroll views delegate to itself in the videoDidLoad()