Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 嵌套UICollectionView存在问题_Ios_Uicollectionview_Uicollectionviewcell - Fatal编程技术网

Ios 嵌套UICollectionView存在问题

Ios 嵌套UICollectionView存在问题,ios,uicollectionview,uicollectionviewcell,Ios,Uicollectionview,Uicollectionviewcell,我有两个嵌套的UICollectionView。外部集合视图的委托是主视图控制器,内部集合视图委托是外部集合视图的UICollectionCell 外部集合视图中只有一个标签,内部集合视图中只有七个,内部集合视图应该包含3或4个单元格(包含3个标签) 问题在于,内部集合视图似乎只更新了两次(对于外部视图中的前两组数据),然后重复更新 以下是外部UICollectionView的cellForItemAtIndexPath - (UICollectionViewCell *)collectionV

我有两个嵌套的UICollectionView。外部集合视图的委托是主视图控制器,内部集合视图委托是外部集合视图的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;
}
。。。这是第二个UICollectionView的cellForItemAtIndexPath,它位于out 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;
}

我希望这是有意义的-请询问是否。。。我只是不明白为什么前1组数据可以,而下5组则不行…

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

使用此设计时,您在管理选择方面有问题吗?您好。。。我使用的集合视图没有进行选择的功能-它们显示一个数据表。一个建议是确保您使用的代理正确设置并正确传播(取决于您在用户选择上的操作位置)。这很棘手。为了获得选择的正确呈现,必须在最外层/父集合视图中处理它。您指的是什么出列方法?你能把你的答案贴在答题纸上以供参考吗?对不起,我知道这是几年后的事了…在这个问题上浪费了太多时间。但解决方案是如此简单:|
- (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;
}