gpt4 book ai didi

ios - TableView 行中 Collection View 的同步水平滚动

转载 作者:行者123 更新时间:2023-12-01 15:59:56 26 4
gpt4 key购买 nike

我正在尝试在表格 View 中同步所有 Collection View 中的滚动(请参见下面的图片链接):

示例图片:
http://postimg.org/image/dduhr89e5/

我能够找到的示例解释了如何通过识别每个 ScrollView 来同步两个单独的 ScrollView 。但是我不确定如何在表格 View 中识别每个 Collection View 。可能有 1 个或数百个都需要同步。

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if ([scrollView isEqual: theFirstScrollView])
{
theSecondScrollView.contentOffset =
CGPointMake(theFirstScrollView.contentOffset.x, 0);
}
else
{
theFirstScrollView.contentOffset =
CGPointMake(theSecondScrollView.contentOffset.x, 0);
}
}

最佳答案

假设每个 Collection View 都有自己的单元格并且 Collection View 的宽度相似(或者至少您已经弄清楚了那部分),这是我将使用的方法:

1) 让您的 VC 成为所有 Collection View 的代表。

2)当它们中的任何一个滚动时,通过 TableViews visibleCells 并设置单元格 collectionView 的内容偏移量。此外,将内容偏移量存储在 viewController 中。

3) 每当一个新单元出列时,将内容偏移设置为 VC 中最后存储的值。

关于ios - TableView 行中 Collection View 的同步水平滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25983373/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com