Synchronizing UIScrollView scrolling

2019-06-18 01:07发布

问题:

I have three UIScrollViews, scrollView1, scrollView2, and scrollView3. When scrollView1 is scrolled then scrollView2 should scroll horizontally with it, and when scrollView3 is scrolled then scrollView2 should scroll vertically with it. How can I do this?

回答1:

The UIScrollViewDelegate protocol includes scrollViewDidScroll:.

You could set the contentOffset of your subserviant scrollviews using setContentOffset in scrollView2 and scrollView3 from scrollView1's delegate's scrollViewDidScroll: