I have an iOS app with a UICollectionView
which presents cells horizontally. In each of the cells, I have added one simple label (for now). These labels are showing names, sometimes the names are short and thats fine... but.... sometimes the names are long and are thus cut off because they cannot fit properly within the width of the collection view cell.
Is there a way to adjust the width of the cell/label dynamically so that the name text will be shown properly?
I was experimenting using this method:
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(106.f, 60.f);
}
But I have two main problems with the above method:
- How do I access the cell label from this method? (So that I can get its height).
- How do I actually figure out what the width of the cell/label needs to be?
Thanks for your time,
Dan