嵌套滚动.自动滚动一个又一个到达终点 [英] Nested Scroll. Auto scroll one after another has reached its end point
问题描述
我有一个嵌套的滚动视图情况,例如follow-
mainView->ScrollView1->ScrollView3(垂直有很多子ScrollView)
*我希望当用户向下滚动时,首先 scrollView1 将滚动拖动显示的 childScrollView3.(scrollView2 的用户交互以及滚动应该被禁用)*
2)*在它结束后,childScrollView3 将以与 scrollView1 滚动的速度相同的速度滚动?*
当用户向下滚动时也会发生同样的情况,即 childScrollView3 将首先结束 &然后 scrollView1 将滚动到顶部.
更新
Mark - 我在 goole 上搜索了视差,但这没有帮助,因为我有一个带有多个垂直子滚动的分页滚动视图.
覆盖func scrollViewDidScroll(_:)
in UIScrollViewDelegate
方法来观察 UIScrollViews 的细粒度滚动.
您可以使用 scrollView 的 contentOffset
变量来查找何时应该开始滚动下一个.您必须做一些数学计算来确定用户触摸的 scrollView 在此方法的调用之间偏移了多少,以确定滚动下一个 scrollView 的幅度以保持两者的动画"相同.>
I have a nested scroll view situation such as follow-
mainView->ScrollView1->ScrollView3(has many child ScrollView vertical)
*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.
override the
func scrollViewDidScroll(_:)
in UIScrollViewDelegate
method to watch for the fine grain scrolling of the UIScrollViews.
You can use the contentOffset
variable of the scrollView to find when you should start scrolling the next one. You'll have to do some math to determine how much the scrollView the user is touching was offset in-between calls of this method to determine how much to scroll the next scrollView by to keep the "animation" the same across both.
这篇关于嵌套滚动.自动滚动一个又一个到达终点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!