Conveniently, UITableView is a subclass of UIScrollView. There is a UIScrollViewDelegate that has this method:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
If you implement this method, you can get the contentOffset property of the contentOffset argument. Then you should use
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
and set a new content offset. So something like this:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { UIScrollView *otherScrollView = (scrollView == self.tableView1) ? self.tableView2 : self.tableView1; [otherScrollView setContentOffset:[scrollView contentOffset] animated:NO]; }
You can use it in a UITableView if you want, but there is no particular reason for this.
source share