How would I get reference to my custom collection view cell inside the method that declares the GCSize?

浪子不回头ぞ 提交于 2020-01-06 02:49:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!