本文介绍了同步UIScrollView滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个UIScrollViews, scrollView1 scrollView2 scrollView3 .滚动 scrollView1 时, scrollView2 应该与其水平滚动,而滚动 scrollView3 时, scrollView2 应该垂直滚动.用它.我该怎么办?

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?

推荐答案

UIScrollViewDelegate协议包括scrollViewDidScroll:.

The UIScrollViewDelegate protocol includes scrollViewDidScroll:.

您可以在scrollView2和scrollView3中使用setContentOffset来设置从属滚动视图的contentOffset,而方法是来自scrollView1的委托的scrollViewDidScroll:

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

这篇关于同步UIScrollView滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 12:45