UICollectionViewを別のUICollectionView内に(一種のテーブルとして)埋め込んでいます。最初のコレクションビューは正常に機能します。正しい数のセルと正しい情報を取得します。ただし、2つ目は、最初の2セットのデータしか表示されません。外部コレクションビューのcellForItemAtIndexPathのコードは次のとおりです。
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Main Tide Data Table Cell";
TideDataTableCell* tideDayDataCell = [self.tideDataTable dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
tidalDate* tideDate = self.tidalDates[indexPath.row];
tideDayDataCell.tides = nil;
tideDayDataCell.tides = [[NSMutableArray alloc] initWithCapacity:0];
tideDayDataCell.tideDataTable.delegate = tideDayDataCell;
tideDayDataCell.tideDataTable.dataSource = tideDayDataCell;
self.tideDataTable.backgroundColor = [UIColor lightGrayColor];
tideDayDataCell.tides = tideDate.tides;
tideDayDataCell.backgroundColor = [UIColor whiteColor];
tideDayDataCell.dayLabel.text = tideDate.dateString;
tideDayDataCell.averageTideHeight = self.avgTideHeight;
return tideDayDataCell;
}
そして、これが正しく機能しない内部コレクションビューのcellForItemAtIndexPathです-最初の2セットのデータを繰り返します...
- (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.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;
}
ご覧のとおり、情報(潮汐)を保持する配列は、呼び出されるたびに初期化され、入力されるデータが可能な限り正しいことを確認しました。助けていただければ幸いです...