Search code examples
iphoneiosuiscrollviewuiscrollviewdelegate

Two scrollView should move together in single touch in any one scrollView


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


Solution

  • 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.