Reputation: 1249
I am working on UIScrollView
and I'm new in programming.
How to scroll two UIScrollView
simultaneous in one touch in any one scrollView
if I scroll 1st scrollView then 2nd scrollView should also move with 1st scrolView
If anyone have idea, pls suggest me
Thanks In Advance
Upvotes: 1
Views: 1485
Reputation: 1540
UIScrollView *otherView = (scrollView==scroll2)?scroll1:scroll2;
CGPoint offSet = otherView.contentOffset;
offSet.y = scrollView.contentOffset.y;
[otherView setContentOffset:offSet];
Upvotes: 1
Reputation: 4500
You can do this with the help of delegate method of UIScrollView
. Here is the demo code for you :
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView == scroll1)
{
scroll2.contentOffset = CGPointMake(content x and y of your scroll1);
}
}
Hope this helps.
Upvotes: 3