两个滚动视图工作同时一触即可 [英] Two scroll view work Simultaneous with one touch

查看:82
本文介绍了两个滚动视图工作同时一触即可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理它的应用程序我必须同时使用两个滚动视图同步。这意味着如果我同时滚动一个滚动视图,则另一个滚动视图必须滚动它。

I am working on application in it I have to work with two scroll view Simultaneous in one touch. It means if I scroll one scroll view at same time another scroll view must scroll with it.

如果可以,那么怎么办呢?

If this is possible then how can it be done?

推荐答案

在包含两个滚动视图的视图控制器中实现UIScrollViewDelegate协议。在:

Implement the UIScrollViewDelegate protocol in the view controller containing both scroll views. In the:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

委托方法,获取内容偏移量:

delegate method, get the content offset:

CGPoint offset = [scrollViewA contentOffset]; // or scrollViewB

然后将另一个控件设置为:

Then set the other control with:

- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated

您可以通过在上面的委托方法中进行比较来确定要更改哪一个:

You can determine which one to change by comparing in the delegate method above:

if( scrollView == scrollViewA ) // change offset of B
else // change offset of A

这篇关于两个滚动视图工作同时一触即可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆