gpt4 book ai didi

ios - 嵌套的 UICollectionViews 问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:31:26 26 4
gpt4 key购买 nike

我有 2 个嵌套的 UICollectionView。外部 Collection View 的委托(delegate)是主视图 Controller ,内部 Collection View 委托(delegate)是外部 Collection View 的 UICollectionCell。

外部 Collection View 只有一个标签和内部 Collection View - 通常有七个,内部 Collection View 应包含 3 或 4 个单元格(包含 3 个标签)。

问题是内部 Collection View 在重复之后似乎只更新了两次(对于外部 View 中的前 2 组数据)。

这是外部 UICollectionView 的 cellForItemAtIndexPath

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Main Tide Data Table Cell";

TideDataTableCell* tideDayDataCell = [self.tideDataTable dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
tideDayDataCell.tideDataTable.delegate = tideDayDataCell;
tideDayDataCell.tideDataTable.dataSource = tideDayDataCell;
tidalDate* tideDate = self.tidalDates[indexPath.row];
tideDayDataCell.thisTidalDate = tideDate;
tideDayDataCell.dayLabel.text = tideDate.dateString;
tideDayDataCell.averageTideHeight = self.avgTideHeight;

tideDayDataCell.backgroundColor = [UIColor whiteColor];
self.tideDataTable.backgroundColor = [UIColor lightGrayColor];
return tideDayDataCell;
}

...这里是第二个 UICollectionView 的 cellForItemAtIndexPath,它位于输出 UICollection View 的 UICollectionViewCell 对象中!

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString* CellIdentifier = @"Tide Info Table Cell";

TidalTideTableCell* tidalTideTableCell = [self.tideDataTable dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
tidalTideTableCell.timeTideLabel.text = @"";
tidalTideTableCell.heightTideLabel.text = @"";
tidalTideTableCell.hwlwTideLabel.text = @"";
self.tideDataTable.backgroundColor = [UIColor clearColor];
Tide* tide = self.thisTidalDate.tides[indexPath.row];
tidalTideTableCell.heightTideLabel.text = [[NSNumber numberWithDouble:tide.height] stringValue];
if (tide.height > self.averageTideHeight)
{
tidalTideTableCell.hwlwTideLabel.text = @"HW";
}
else
{
tidalTideTableCell.hwlwTideLabel.text = @"LW";
}
tidalTideTableCell.timeTideLabel.text = tide.date;
tidalTideTableCell.backgroundColor = [UIColor clearColor];
return tidalTideTableCell;
}

我希望这是有道理的 - 请询问它是否...我只是不明白为什么前 1 组数据没问题,而后 5 组数据却不行...

最佳答案

这是通过在母(外部)UICollectionView 的出队方法中调用 [UICollectionView refreshdata] 解决的

关于ios - 嵌套的 UICollectionViews 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13741706/

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