问题
I have a collection view with custom view cells..
I am trying to get the reference of the cell where it's defining the height:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
CGFloat screenWidth = screenSize.width;
MyCustomCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:DequeueMyCustomReusableCell forIndexPath:indexPath];
return CGSizeMake(screenWidth, [cell calculatedHeight]);
}
This does not work.. What should I do?
Nor does this:
MyCustomCell *cell = (MyCustomCell *)[collectionView cellForItemAtIndexPath:indexPath];
来源:https://stackoverflow.com/questions/30402620/how-would-i-get-reference-to-my-custom-collection-view-cell-inside-the-method-th