In my app, I have two tableViews side by side. When the user scrolls on, I would like the second one to scroll at the same time, so it looks almost like one table with two d
also, the tableview that got scrolled by the user should not be sent setContentOffset: message in scrollViewDidScroll, since it will get the app into endless cycle. so additional UIScrollViewDelegate methods should be implemented in order to solve the problem:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
beingScrolled_ = nil;
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if(beingScrolled_ == nil)
beingScrolled_ = scrollView;
}
and modifying Inspire48's version scrollViewDidScroll: accordingly:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
UIScrollView *otherScrollView = (scrollView == self.tableView1) ? self.tableView2 : self.tableView1;
if(otherScrollView != beingScrolled)
{
[otherScrollView setContentOffset:[scrollView contentOffset] animated:NO];
}
}
where beingScrolled_ is an ivar of type UIScrollView