问题
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.
回答1:
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.
回答2:
You will have to intercept the touches and manually send a scrollTo: message to both scrollviews.
来源:https://stackoverflow.com/questions/1438661/perform-synchronized-scrolling-with-two-scroll-views