Skip to content

Commit

Permalink
Fix items search bar placement iOS 18 bug (#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvasilak authored Nov 28, 2024
1 parent ba48669 commit 6c76c8e
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ class BaseItemsViewController: UIViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if #available(iOS 18, *) {
// In some cases in iOS 18, where the horizontal size class changes, e.g. when switching to a scene with a PDF reader and dismissing it,
// this error is logged multiple times, and leaves the search bar in stack placement, but overlapping the table view:
// "UINavigationBar has changed horizontal size class without updating search bar to new placement. Fixing, but delegate searchBarPlacement callbacks have been skipped."
// Setting "navigationItem.preferredSearchBarPlacement = .inline" explicitly, would even freeze the app and crash it.
// Instead, hiding and showing the navigation bar momentarily when the view will appear, fixes the issue.
navigationController?.setNavigationBarHidden(true, animated: false)
navigationController?.setNavigationBarHidden(false, animated: false)
}
toolbarController?.willAppear()
}

Expand Down

0 comments on commit 6c76c8e

Please sign in to comment.