0
votes

I am developing an application in iPad.

In this , I am using two UIScrollView Controllers.

When User Scrolling First Scroll View ,the Second Scroll view also have to scroll programmatically.

Similarly When user scrolling 2nd scroll view First scroll view need to scroll. How to Handle these 2 scroll views in a same View.

I have tried - (void)scrollViewDidScroll:(UIScrollView *)scrollView; method of the UIScrollViewDelegate. But the Scroll is not Smooth.

Please suggest me any other way to do this .

My Code is :

- (void)scrollViewDidScroll:(UIScrollView *)scrollView 
  {

      if(scrollView == sub )

      {

         if(sub.isDragging)
         {

             NSLog(@"Sub");
             float x = main.contentSize.width/sub.contentSize.width;
             CGPoint offset  = CGPointMake((sub.contentOffset.x*x), sub.contentOffset.y);
             [main setContentOffset:offset animated:NO];

         }

      }

      else if(scrollView == main )

      {

         if(main.isDragging)

         {

             float x = main.contentSize.width/sub.contentSize.width;
             CGPoint offset  = CGPointMake((main.contentOffset.x/x), main.contentOffset.y);
             [sub setContentOffset:offset animated:NO];
        }
     }

  }
1

1 Answers

1
votes

Try to use

- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated

instead of setContentOffset. And set animated to YES it will be smoother!