collectionview cell sizes are now not calculated upfront 😭

need to fix why theyre not expanding horizontally and that theyre too big
This commit is contained in:
Nihaal Sharma committed 2026-05-08 14:41:58 +01:00
1 parent 744271fbb3
commit 90f277282e
2 files changed
+6 -4

No files matched your search

@@ -104,10 +104,11 @@ class EmojiCollectionViewCell: PlainEmojiCollectionViewCell {
} }
override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes { override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
super.preferredLayoutAttributesFitting(layoutAttributes) let layoutAttributes = super.preferredLayoutAttributesFitting(layoutAttributes)
guard label.text != nil else { return layoutAttributes } guard label.text != nil else { return layoutAttributes }
let labelHeight = label.sizeThatFits(CGSize(width: self.contentView.frame.width, height: .infinity)).height let labelHeight = label.sizeThatFits(CGSize(width: layoutAttributes.size.width, height: .infinity)).height
layoutAttributes.size = CGSize(width: self.contentView.frame.width, height: labelHeight+4+view.frame.height) layoutAttributes.size = CGSize(width: layoutAttributes.size.width, height: labelHeight+4+view.frame.height)
print(label.text!, layoutAttributes.size)
return layoutAttributes return layoutAttributes
} }
@@ -81,7 +81,8 @@ class PlainEmojiCollectionViewCell: UICollectionViewCell {
} }
let totalSpacing = (collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.minimumInteritemSpacing ?? 0 * (cols-1) let totalSpacing = (collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.minimumInteritemSpacing ?? 0 * (cols-1)
let itemWidth = (availWidth-totalSpacing)/cols let itemWidth = (availWidth-totalSpacing)/cols
layoutAttributes.size = CGSize(width: itemWidth, height: layoutAttributes.size.height) layoutAttributes.size = CGSize(width: itemWidth, height: itemWidth)
print(layoutAttributes.size)
return layoutAttributes return layoutAttributes
} }
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.