Search code examples
iosuiscrollviewuiscrollviewdelegate

scrollView.dragging == true after scrollViewDidEndDragging?


It seems that in the UIScrollViewDelegate function

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

sometimes, scrollView.dragging is true even after

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)willDecelerate

is called.

Is that somehow expected?


Solution

  • If willDecelerate of scrollViewDidEndDragging:willDecelerate: is YES, then yes, that's expected. You get scrollViewDidEndDragging when the user lets go of the drag, but dragging doesn't change until the visual scrolling/decelerating is done. Thus, when you let go of a drag, you may see scrollViewDidEndDragging followed by some scrollViewDidScroll (and dragging still YES).

    Alternatively, you can check out tracking, which turns to NO as soon as the user lets go (even though the scroll view may still be scrolling).