-2

Is there a way to detect and respond when an UITableView is scrolling up and down? I would like to show a button at the bottom of the screen when the user scrolls down and hide it when the user scrolls up.

Thanks!

Matthew S.
  • 701
  • 1
  • 5
  • 22
ecat87
  • 11
  • 3

1 Answers1

3

You should look at the UIScrollViewDelegate. Since the UITableViewDelegate is a subclass of the UIScrollViewDelegate, you can, in your view controller, set your UITableView's delegate to self. With this, you can now implement the

-scrollViewWillEndDragging:withVelocity:targetContentOffset:

method in your view controller. If the y point of velocity is positive, the user is scrolling down. If the y point of velocity is negative, the user is scrolling up. You can use this information to set the visibility of your button.

Matthew S.
  • 701
  • 1
  • 5
  • 22