iPhone - 如何对称滚动两个UITableViews [英] iPhone - how to scroll two UITableViews symmetrically

查看:116
本文介绍了iPhone - 如何对称滚动两个UITableViews的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我有两个并排的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆