Skip to content

Commit 5f23a0b

Browse files
committed
debug: Negative sizes are not supported in the flow layout
1 parent c351152 commit 5f23a0b

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

SectionKit2.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'SectionKit2'
3-
s.version = '2.0.17'
3+
s.version = '2.0.18'
44
s.summary = '动态表单框架'
55
s.homepage = "https://github.com/linhay/SectionKit"
66
s.license = { :type => 'Apache', :file => 'LICENSE' }

SectionUI.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'SectionUI'
3-
s.version = '2.0.17'
3+
s.version = '2.0.18'
44
s.summary = '动态表单框架'
55
s.homepage = "https://github.com/linhay/SectionKit"
66
s.license = { :type => 'Apache', :file => 'LICENSE' }
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
1111

1212
s.platform = :ios
1313
s.ios.deployment_target = "13.0"
14-
s.dependency 'SectionKit2', '>= 2.0.17'
14+
s.dependency 'SectionKit2', '>= 2.0.18'
1515

1616
s.source_files = ["Sources/SectionUI/**/*.{swift,h}"]
1717
end

Sources/SectionKit/CollectionBaseProtocol/SKCViewDelegateFlowLayout.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,21 @@ class SKCViewDelegateFlowLayout: SKCDelegate, UICollectionViewDelegateFlowLayout
2828
guard let section = self.section(indexPath) else {
2929
return .zero
3030
}
31-
let size = section.itemSize(at: indexPath.item)
32-
if indexPath.section == 0, indexPath.row == 0, size == .zero {
33-
return .init(width: 0.01, height: 0.01)
34-
} else {
35-
return size
31+
32+
var size = section.itemSize(at: indexPath.item)
33+
34+
if size.width < 0 || size.height < 0 {
35+
assertionFailure("Negative sizes are not supported in the flow layout, \(section)")
36+
size = .init(width: max(size.width, 0), height: max(size.height, 0))
3637
}
38+
39+
if indexPath.section == 0,
40+
indexPath.row == 0,
41+
size == .zero {
42+
size = .init(width: 0.01, height: 0.01)
43+
}
44+
45+
return size
3746
}
3847

3948
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {

0 commit comments

Comments
 (0)