嵌套UICollectionViews的问题

Hil*_*ich 2 ios uicollectionview uicollectionviewcell

我有2个嵌套的UICollectionViews.外部集合视图的委托是主视图控制器,内部集合视图委托是外部集合视图的UICollectionCell.

外部集合视图只有一个标签和内部集合视图 - 通常会有七个,内部集合视图应包含3或4个单元格(包含3个标签).

问题是内部集合视图似乎只是在重复之后才更新两次(对于外部视图中的前两组数据).

这是外部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;
}
Run Code Online (Sandbox Code Playgroud)

...这里是第二个UICollectionView的cellForItemAtIndexPath,它位于UICollection视图的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;
}
Run Code Online (Sandbox Code Playgroud)

我希望这是有道理的 - 请问它是不是......我只是不明白为什么它可以用于前1组数据然后不用于接下来的5组......

Hil*_*ich 5

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