iPhone - 如何对称滚动两个UITableViews [英] iPhone - how to scroll two UITableViews symmetrically
问题描述
在我的应用中,我有两个并排的tableViews。当用户滚动时,我希望第二个同时滚动,所以它看起来几乎像一个有两个不同列的表。我有点失去了如何去做这个,有什么建议吗?
In my app, I have two tableViews side by side. When the user scrolls on, I would like the second one to scroll at the same time, so it looks almost like one table with two different columns. I'm a bit lost on how to go about doing this, any suggestions?
谢谢,
Greg
Thanks, Greg
推荐答案
你要查看 UIScrollViewDelegate
- 说你有两个滚动视图, A 和 B 。
You'll want to look into the UIScrollViewDelegate
- say you've got two scroll views, A and B.
使用滚动视图 A 的 scrollViewDidScroll
委托方法获取偏移量,然后在同一个方法中,在滚动视图 B 上调用 setContentOffset
,传入从代理获得的值。
Use the scrollViewDidScroll
delegate method of scroll view A to get the offset, and then in the same method call setContentOffset
on scroll view B, passing in the value you get from the delegate.
一旦你设置了委托方法,它实际上不应该超过2-3行代码。
It actually shouldn't be more than 2-3 lines of code once you've set-up your delegate methods.
这篇关于iPhone - 如何对称滚动两个UITableViews的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!