I have an iOS app c UICollectionView
that represents cells horizontally. In each of the cells, I added one simple label (for now). These labels show names, sometimes the names are short, and that's fine ... but .... sometimes the names are long and thus cropped because they cannot fit correctly into the width of the cell of the collection view.
Is there a way to adjust the cell / label width dynamically so that the title text displays correctly?
I experimented 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 to access cell label from this method? (So that I can get its height).
- How can I determine what the width of the cell / label should be?
Thank you for your time,
Dan