I have a screen with several scrollViews. How to achieve this:
When i tap on one and swipe they all start to scroll. I of course know UIScrollViewDelegate
methods and what i trying to do so far is combine -setContentOffset:animated:
with scrollViewDidScroll
and it works but only for one case - when i start scrolling with delegate scrollview.
How to dynamically change delegate? depends which scroll view user select?
Keep an array of all of your UIScrollView
objects. Make sure all of their delegates point to the same object (or if that's not possible, there is some sort of handler that gets called on scrollViewDidScroll
). Then use setContentOffset
to adjust the offsets. You had the right idea, but you just want to make sure all scroll views except the current view (which is determined by the delegate method argument) is scrolling.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
for (UIScrollView *view in self.scrollViews) {
if (scrollView != view) {
[view setContentOffset:scrollView.contentOffset];
}
}
}