Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit 1a74ed4

Browse files
author
Amir Khorsandi
committed
Fix zero sections issue
1 parent 833a71a commit 1a74ed4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/CollectionViewPagingLayout.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public class CollectionViewPagingLayout: UICollectionViewLayout {
6161
}
6262

6363
private var numberOfItems: Int {
64-
(0..<(collectionView?.numberOfSections ?? 0))
64+
guard let numberOfSections = collectionView?.numberOfSections, numberOfSections > 0 else {
65+
return 0
66+
}
67+
return (0..<numberOfSections)
6568
.compactMap { collectionView?.numberOfItems(inSection: $0) }
6669
.reduce(0, +)
6770
}

0 commit comments

Comments
 (0)