From 7342f6d4b4af660c0e4e44afca410a9cb62f1f7c Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 3 Oct 2019 12:30:53 -0700 Subject: [PATCH] Fixes crash on launch on iOS 13 --- AltStore/News/NewsViewController.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/AltStore/News/NewsViewController.swift b/AltStore/News/NewsViewController.swift index b04f0af0..9e0ca0a3 100644 --- a/AltStore/News/NewsViewController.swift +++ b/AltStore/News/NewsViewController.swift @@ -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