UITableView Scroll event

If you implement the UITableViewDelegate protocol, you can also implement one of the UIScrollViewDelegate methods:

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

or

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

For example, if you have a property called tableView:

// ... setting up the table view here ...
self.tableView.delegate = self;
// ...

// Somewhere in your implementation file:
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    NSLog(@"Will begin dragging");
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"Did Scroll");
}

This is because UITableViewDelegate conforms to UIScrollViewDelegate, as can be seen in the documentation or in the header file.

Leave a Comment