I have a vertical collectionview with label and in my flowlayout i am using UICollectionViewFlowLayoutAutomaticSize
to resize the cell size but it is giving me error when i give very long string to the label, number of line in label
set to 0
Error
Please check the values returned by the delegate. The relevant
UICollectionViewFlowLayout instance is UICollectionViewFlowLayout ,and it is attached to UICollectionView; frame = (0 88; 375 690); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = NSArray layer = CALayer; contentOffset: {0, 0}; contentSize: {375, 2}; adjustedContentInset: {0, 0, 0, 0}> collection view layout: UICollectionViewFlowLayout
Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
The behavior of the UICollectionViewFlowLayout is not defined because the item width must be less than the width of the UICollectionView minus the section insets left and right values, minus the content insets left and right values
Constraints
Code
let array = ["Hello", Array(repeating: "Hello", count: 100).joined(), "blah"]
// on viewDidLoad method
if let flowLayout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
flowLayout.estimatedItemSize = CGSize(width: 1, height: 1)
flowLayout.itemSize = UICollectionViewFlowLayoutAutomaticSize
}