From 17abda66ba892c4495c6d819b27cd6dfd1ce9482 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Wed, 8 Feb 2023 13:06:44 -0600 Subject: [PATCH] Fixes SourcesViewController crash on iOS 12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently changing NSLayoutConstraint priorities from required to optional (and vice versa) isn’t supported, even though it works on iOS 13+. Who knew! --- AltStore/Base.lproj/Main.storyboard | 8 ++++---- AltStore/Sources/SourcesViewController.swift | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/AltStore/Base.lproj/Main.storyboard b/AltStore/Base.lproj/Main.storyboard index b7041ee1..85234248 100644 --- a/AltStore/Base.lproj/Main.storyboard +++ b/AltStore/Base.lproj/Main.storyboard @@ -1002,10 +1002,10 @@ World - - - - + + + + diff --git a/AltStore/Sources/SourcesViewController.swift b/AltStore/Sources/SourcesViewController.swift index 96ff8798..8c86ecc7 100644 --- a/AltStore/Sources/SourcesViewController.swift +++ b/AltStore/Sources/SourcesViewController.swift @@ -500,11 +500,12 @@ extension SourcesViewController: UICollectionViewDelegateFlowLayout headerView.layoutMargins.left = self.view.layoutMargins.left headerView.layoutMargins.right = self.view.layoutMargins.right - let almostRequiredPriority = UILayoutPriority(UILayoutPriority.required.rawValue - 1) // Can't be required or else we can't satisfy constraints when hidden (size = 0). - headerView.leadingLayoutConstraint?.priority = almostRequiredPriority - headerView.trailingLayoutConstraint?.priority = almostRequiredPriority - headerView.topLayoutConstraint?.priority = almostRequiredPriority - headerView.bottomLayoutConstraint?.priority = almostRequiredPriority + /* Changing NSLayoutConstraint priorities from required to optional (and vice versa) isn’t supported, and crashes on iOS 12. */ + // let almostRequiredPriority = UILayoutPriority(UILayoutPriority.required.rawValue - 1) // Can't be required or else we can't satisfy constraints when hidden (size = 0). + // headerView.leadingLayoutConstraint?.priority = almostRequiredPriority + // headerView.trailingLayoutConstraint?.priority = almostRequiredPriority + // headerView.topLayoutConstraint?.priority = almostRequiredPriority + // headerView.bottomLayoutConstraint?.priority = almostRequiredPriority switch kind {