How to know in which way UITableView is being scrolled
-(void) scrollViewDidScroll:(UIScrollView *)scrollView{ CGPoint currentOffset = scrollView.contentOffset; if (currentOffset.y > self.lastContentOffset.y) { // Downward } else { // Upward } self.lastContentOffset = currentOffset;}
-(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{ if (velocity.y > 0){ NSLog(@"up"); } if (velocity.y < 0){ NSLog(@"down"); }}
Could we do like this?
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { if ([scrollView.panGestureRecognizer translationInView:scrollView].y > 0) { // down } else { // up } }