Search code examples
iosuiscrollviewtouchesbegantouchesmoved

UIScrollView - tell the difference between setContentOffset and manual scrolling


I have a scrollview, which automatically advances every 3 seconds to the next "page" (page control also used). However, once the user touches the scrollview, I want to stop the auto-advancing.

I have subclassed the scrollview. I can detect touchesBegan in the subclass, but touchesMoved is not called, so I can't tell if the user has manually swiped the scrollview. I can't use scrollviewDidScroll, because that gets called when I set the contentOffset when the auto-advance timer fires.

So what are my other options for detecting touches? Why isn't touchesMoved called on the scrollview subclass?


Solution

  • Thank you for the suggestions. They helped me stumble upon this easy solution:

    - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
    {
        [self.scrollTimer invalidate];
    }