I am developing a news feed application which needs to display a photo and text below it. For some items the text is not present and I need to reduce the size of cell depending on it. How do I achieve it ? This is what I have.
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
[collectionView reloadData];
CGSize size;
if (!reviewExist)
{
size = CGSizeMake(collectionViewFrame.frame.size.width, collectionViewFrame.frame.size.height/3);
}
else
{
size = CGSizeMake(collectionViewFrame.frame.size.width, collectionViewFrame.frame.size.height);
}
return size;
}
Now review text can be big or small. How do I calculate the cell height and dynamically pass it ?
Aucun commentaire:
Enregistrer un commentaire