4

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.

Thanks in Advance.

Vishal.

rein
  • 32,967
  • 23
  • 82
  • 106
Vishal Mali
  • 71
  • 1
  • 8

2 Answers2

6

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);
  }
}

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

luvieere
  • 37,065
  • 18
  • 127
  • 179
  • Hi Luvieere, Thanks for your great herlp. It worked at my side. Yupppppy. Once again Thanks for your time. Ragards, ViShAl. – Vishal Mali Sep 18 '09 at 05:56
  • when you change the contentOffset of the other scrollview, I think that scrollViewDidScroll is triggered for it... leading to a recursive bounceback which stops slower than normally due to the deceleration factor – Radu Simionescu Dec 13 '13 at 21:37
0

You will have to intercept the touches and manually send a scrollTo: message to both scrollviews.

coneybeare
  • 33,113
  • 21
  • 131
  • 183
  • Can you please elaborate on this as i am new to application development or do you know any sample that will help me. Thanks, Vishal. – Vishal Mali Sep 17 '09 at 13:00