When I call the following delegate method:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
float cellWidth = 90.0f; float cellHeight = 60.0f;
int cellType = [[collectionView cellForItemAtIndexPath:indexPath] tag];
return CGSizeMake(cellWidth, cellHeight);
}
cellType returns 0. [collectionView cellForItemAtIndexPath:] also returns nil
I am guessing this is because the cell is not sized, so it is not displayed, and when it's not displayed, it returns nil (i.e. this method is called prior to the instance of the cell object being created).
Is there a way to get information that was set for this item in the collectionView:cellForItemAtIndexPath method? How can an individual cell type be identified within the sizeForItemAtIndexPath method?
(I plan on using the data source NSArray, but I was trying to keep this logic within the display object, and not managed by the data.)
Thinking here of doing something like:
But I don't know if cell will return a value or not in the sizeForCell Method