Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know in which way UITableView is being scrolled

Tags:

Is there any way in which we can know if a UITableView is being scrolled in upward direction or downward direction?

like image 528
A for Alpha Avatar asked Jul 18 '12 08:07

A for Alpha


People also ask

Is UITableView scrollable?

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).

What is Tableview content offset?

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.


2 Answers

-(void) scrollViewDidScroll:(UIScrollView *)scrollView {     CGPoint currentOffset = scrollView.contentOffset;     if (currentOffset.y > self.lastContentOffset.y)     {         // Downward     }     else     {         // Upward     }     self.lastContentOffset = currentOffset; } 
like image 159
citydeer Avatar answered Sep 17 '22 15:09

citydeer


-(void)scrollViewWillEndDragging:(UIScrollView *)scrollView                      withVelocity:(CGPoint)velocity               targetContentOffset:(inout CGPoint *)targetContentOffset{      if (velocity.y > 0){         NSLog(@"up");     }     if (velocity.y < 0){         NSLog(@"down");     } } 
like image 34
Alex Avatar answered Sep 21 '22 15:09

Alex