alexmngn
alexmngn

Reputation: 9587

Double UIScrollView synchronization - Different height

I'm currently developping iPad application with 2 UIScrollView in the same page. On the left side, there is the content and on the right side, there are some bloc, news. These two UIScrollView are different height size.

Example : left 1000, right 2000.

I would like to synchronize the 2 UIScrollView, I explain me :

When the user scrolls on the left UIScrollView to access on the bottom, the right UIScrollView "scrolls" in the same time. If the left UIScrollView is happened to be at the bottom, and the right UIScrollView is NOT on the bottom, the right UIScrollView continue to scroll until ... it stop naturally.
And the same behavior if the user scroll on the right UIScrollView.

Do you have an idea how to resolve or to handle my problem ?

Upvotes: 0

Views: 1018

Answers (2)

user1678960
user1678960

Reputation: 21

I'll just post the solution I used in case anyone gets to this question in the future.

You don't set the contentOffset directly. You need to do a workaround. Like so:

CGRect viewToUpdateBounds = viewToUpdate.bounds;
viewToUpdateBounds.origin = scrolledView.contentOffset;
viewToUpdate.bounds = viewToUpdateBounds;

Regards

Upvotes: 2

mariusLAN
mariusLAN

Reputation: 1205

You have to listen to the delegate method of scrollViewDidScroll then you can set the contentOffset of the second UIScrollView.

Upvotes: 2

Related Questions