使用两个滚动视图执行同步滚动 [英] Perform synchronized scrolling with two scroll views

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

问题描述

我在同一视图中有两个滚动条(例如2个垂直滚动条).我想做类似的事情,当我滚动一个滚动条时,另一个滚动条也应与第一个滚动条移动相同的量,并且方向相同.

I have two scrollers in same view(like 2 vertical scrollers). I want to do something like, when i scroll one scroller the another scroll should also move by the same amount and in same direction as first one.

有什么办法可以实现这一目标???任何样品都将不胜感激.

Is there any way i can achieve this??? Any sample will be really appreciated.

预先感谢.

Vishal.

推荐答案

我认为我已经做到了...我做到了:

I think I've done this... I did it like this:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
  if ([scrollView isEqual: theFirstScrollView])
  {
        theSecondScrollView.contentOffset =
              CGPointMake(theFirstScrollView.contentOffset.x, 0);
  }
  else
  {
        theFirstScrollView.contentOffset = 
              CGPointMake(theSecondScrollView.contentOffset.x, 0);
  }
}

scrollview必须共享相同的委托,并且它处理scrollViewDidScroll方法中的行为.

The scrollviews must share the same delegate, and it handles the behavior in the scrollViewDidScroll method.

这篇关于使用两个滚动视图执行同步滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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