Double UIScrollView synchronization - Different height

社会主义新天地 提交于 2019-12-12 01:42:52

问题


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 ?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/9207474/double-uiscrollview-synchronization-different-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!