
1.png
联动效果:
实现tableviewA滑动的同时tableviewB跟着滑动,tableviewB滑动的同时tableviewA跟着滑动,tablviewB可以实现左右滑动。
方法:
在scrollDid里建立tableviewA和tableviewB的关系。
在滑动tableviewA时候 关联tableviewB ,tablviewB的偏移Y与tableviewA相同。
//建立titleTbaleview和inforTableview的滑动关联
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == tablviewA) {
[tableviewB setContentOffset:CGPointMake(tablviewB.contentOffset.x, tableviewA.contentOffset.y)];
}
if (scrollView ==tablviewB) {
[tablviewA setContentOffset:CGPointMake(0, tablviewB.contentOffset.y)];
}
}
本文介绍了一种实现两个TableView同步滑动的方法。通过在scrollViewDidScroll方法中设置tableviewA和tableviewB的内容偏移量,使得tableviewA滑动时tableviewB跟随滑动,反之亦然。此外,tableviewB还支持左右滑动。
1098

被折叠的 条评论
为什么被折叠?



