self.collection.collectionViewLayout.invalidateLayout()
self.collection.setCollectionViewLayout(self.mosaicLayout, animated: true)
collection.delegate = self
collection.dataSource = self
collection.reloadData()
}
func collectionView(_ collectionView: UICollectionView, mozaik layout: ADMozaikLayout, mozaikSizeForItemAt indexPath: IndexPath) -> ADMozaikLayoutSize {
if indexPath.item == 0 {
return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 1)
}
if indexPath.item % 8 == 0 {
return ADMozaikLayoutSize(numberOfColumns: 2, numberOfRows: 2)
}
else if indexPath.item % 6 == 0 {
return ADMozaikLayoutSize(numberOfColumns: 3, numberOfRows: 1)
}
else if indexPath.item % 4 == 0 {
return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 3)
}
else {
return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 1)
}
}
func collectonView(_ collectionView: UICollectionView, mozaik layoyt: ADMozaikLayout, geometryInfoFor section: ADMozaikLayoutSection) -> ADMozaikLayoutSectionGeometryInfo {
let width = UIScreen.main.bounds.width/5
let rowHeight: CGFloat = width//layoutType == .portrait ? 93 : 110
let columns = [ADMozaikLayoutColumn(width: width), ADMozaikLayoutColumn(width: width), ADMozaikLayoutColumn(width: width), ADMozaikLayoutColumn(width: width)]
let geometryInfo = ADMozaikLayoutSectionGeometryInfo(rowHeight: rowHeight, columns: columns, minimumInteritemSpacing: 5,minimumLineSpacing: 5,sectionInset: UIEdgeInsets(top: 5, left: 0, bottom: 5, right: 0),headerHeight: 0, footerHeight: 0)
return geometryInfo
}
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 100
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PostCell.reuseIdentifier, for: indexPath)
cell.backgroundColor = .red
return cell
}
This is how i configured the collectionview the library crashes on Crash on ADMozaikLayoutSectionMatrixError.rowOutOfBounds