Fixes SourcesViewController crash on iOS 12

Apparently changing NSLayoutConstraint priorities from required to optional (and vice versa) isn’t supported, even though it works on iOS 13+. Who knew!
This commit is contained in:
Riley Testut
2023-02-08 13:06:44 -06:00
committed by Magesh K
parent f16e9c75b4
commit 17abda66ba
2 changed files with 10 additions and 9 deletions

View File

@@ -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) isnt 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
{