Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit 8179736

Browse files
author
Oscar Apeland
committed
Now doesnt crash on 4 inch devices, v 0.1.10
1 parent 61ed543 commit 8179736

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

SwipeableViewController.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 = 'SwipeableViewController'
3-
s.version = '0.1.9'
3+
s.version = '0.1.10'
44
s.summary = 'A small UI component to build UIPageViewController-y views in your app.'
55

66
s.description = <<-DESC

SwipeableViewController/Source/SwipeableCollectionViewFlowLayout.swift

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@ open class SwipeableCollectionViewFlowLayout: UICollectionViewFlowLayout {
1919
setup()
2020
}
2121

22+
private var collectionViewObservation: NSKeyValueObservation?
2223
private func setup() {
23-
sectionInset = UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 10.0)
24-
estimatedItemSize = CGSize(width: 60.0, height: 52.0)
25-
minimumInteritemSpacing = .leastNonzeroMagnitude
26-
minimumLineSpacing = .leastNonzeroMagnitude
27-
scrollDirection = .horizontal
24+
collectionViewObservation = observe(\.collectionView, options: [.new]) { (layout, change) in
25+
guard let newCollectionView = change.newValue as? UICollectionView else {
26+
return
27+
}
28+
29+
self.sectionInset = UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 10.0)
30+
self.estimatedItemSize = CGSize(width: 60, height: newCollectionView.frame.height)
31+
self.minimumInteritemSpacing = .leastNonzeroMagnitude
32+
self.minimumLineSpacing = .leastNonzeroMagnitude
33+
self.scrollDirection = .horizontal
34+
}
35+
2836
}
2937
}

0 commit comments

Comments
 (0)