Fixes crash on launch on iOS 13

This commit is contained in:
Riley Testut
2019-10-03 12:30:53 -07:00
parent 198e7c7caf
commit 7342f6d4b4

View File

@@ -55,8 +55,6 @@ class NewsViewController: UICollectionViewController
self.prototypeCell.translatesAutoresizingMaskIntoConstraints = false
self.prototypeCell.contentView.translatesAutoresizingMaskIntoConstraints = false
self.collectionView.contentInset.bottom = 20
self.collectionView.dataSource = self.dataSource
self.collectionView.prefetchDataSource = self.dataSource
@@ -74,6 +72,18 @@ class NewsViewController: UICollectionViewController
self.fetchSource()
}
override func viewWillLayoutSubviews()
{
super.viewWillLayoutSubviews()
if self.collectionView.contentInset.bottom != 20
{
// Triggers collection view update in iOS 13, which crashes if we do it in viewDidLoad()
// since the database might not be loaded yet.
self.collectionView.contentInset.bottom = 20
}
}
}
private extension NewsViewController