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.
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).
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.
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;
}
... 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;
}
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...