Nested Scroll. Auto scroll one after another has reached its end point

时间:2016-03-02 11:02:26

标签: ios swift uiscrollview

I have a nested scroll view situation such as follow-

mainView->ScrollView1->ScrollView3(has many child ScrollView vertical)

enter image description here

*I want that when that when the user scrolls down then,first the scrollView1 will scroll dragging the displayed childScrollView3 along with it.(scrollView2's user interaction as well as scroll should be disabled)*

2)*And after it has reached its end the childScrollView3 will scroll with the same velocity that scrollView1 was scrolling ?*

Same should happen when user scrolls downward i.e childScrollView3 will first come to its end & then the scrollView1 shall scroll to top.

UPDATE

Mark - I searched on goole for parallax but that was not helpful as I have a paging scroll view with multiple vertical child scrolls.

1 个答案:

答案 0 :(得分:0)

覆盖 func scrollViewDidScroll(_:)中的UIScrollViewDelegate 观察UIScrollViews细粒度滚动的方法。

您可以使用scrollView的contentOffset变量来查找何时应该开始滚动下一个。你必须做一些数学运算来确定用户正在触摸的scrollView在此方法的调用之间的偏移量,以确定滚动下一个scrollView的数量,以保持两个“动画”相同。