嵌套 UICollectionViews 的问题 [英] Issue with nested UICollectionViews

查看:27
本文介绍了嵌套 UICollectionViews 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have 2 nested UICollectionViews. The delegate for the outer collection view is the main view controller, and the inner collection views delegate is the UICollectionCell of the outer collection view.

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

The outer collection view has only a label and the inner collection view in it - normally there would be seven of these, the inner collection view should contain 3 or 4 cells (containing 3 labels).

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

The problem is that the inner collection view only seems to get updated twice (for the first 2 sets of data in the outer views) after that they repeat.

这是外部 UICollectionView 的 cellForItemAtIndexPath

Here is the cellForItemAtIndexPath for the outer UICollectionView

- (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,它位于 UICollectionViewCell 对象中,用于输出 UICollection 视图!

... and here is the cellForItemAtIndexPath for the second UICollectionView which is in the UICollectionViewCell object for the out UICollection view!

- (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 组不行...

I hope this makes sense - please ask if it's not... I just don't understand why it's ok for the first 1 sets of data and then not for the next 5...

推荐答案

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

This was resolved by calling [UICollectionView refreshdata] in the dequeue method for the mother (outer) UICollectionView

这篇关于嵌套 UICollectionViews 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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