Detect direction of UIScrollView scroll in scrollViewWillBeginDragging

后端 未结 9 1832
心在旅途
心在旅途 2020-12-17 09:30

I did google enough, & I did check posts like these ( Finding the direction of scrolling in a UIScrollView? ) in stackoverflow before posting this. I have a dynamic numb

9条回答
  •  一个人的身影
    2020-12-17 10:09

    This is what I used and it works nicely at least on iOS 6.0:

    - (void)scrollViewDidScroll:(UIScrollView*)scrollView
    {
       CGPoint translation = [scrollView.panGestureRecognizer translationInView:scrollView];
    
       // Detect direction by accessing x or y of translation
    }
    

    Saves you the instance variable for lastContentOffset ...

提交回复
热议问题