I am using UICollectionView using the flow layout. I have made a custom UICollectionView with horizontal. error-
The behavior of the UICollectionViewFlowLayout is not defined because: the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
The relevant UICollectionViewFlowLayout instance is , and it is attached to ; layer = ; contentOffset: {-8, -8}; contentSize: {0, 100}> collection view layout: . 2019-11-18 11:51:59.017124+0530 eVyapaar_Grocery[3964:1811183] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
Here is my code: collectionView.delegate = self collectionView.dataSource = self collectionView.register(UINib(nibName: "cellID", bundle: nil), forCellWithReuseIdentifier:"cellID") collectionView.contentInset = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8) collectionView.showsHorizontalScrollIndicator = false collectionView.isScrollEnabled = true if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout { layout.scrollDirection = .horizontal collectionView!.collectionViewLayout = layout } extension ViewController: UICollectionViewDelegateFlowLayout { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { if collectionView == myCcollectionView { var width: CGFloat = 0 if UIDevice.isIpad { width = ((UIScreen.main.bounds.width/6)-6) } else { width = ((UIScreen.main.bounds.width/3)-6) } return CGSize(width: width, height: width) } } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { return 1 } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { return 0 } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } }