Is there any way in which we can know if a UITableView
is being scrolled in upward direction or downward direction?
UITableView is a subclass of UIScrollView that allows users to scroll the table vertically (the closely-related UICollectionView class allows for horizontal scrolling and complex two-dimensional layouts).
contentOffset is the point at which the origin of the content view is offset from the origin of the scroll view. In other words, it is where the user has currently scrolled within the scroll view. This obviously changes as the user scrolls.
-(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"); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With