Unexpected UINavigationBar Behavior During View Transitions in iOS 18

In iOS 18, I've observed unexpected behavior related to the UINavigationBar when transitioning between view controllers that have differing navigation bar visibility settings. Specifically, when returning from a modal presentation or a web view, the navigation bar reappears with an unexpected height (e.g., 103 points) and lacks content, displaying only an empty bar.

Start with a UIViewController (e.g., HomeViewController) where the navigation bar is hidden using:

override func viewWillAppear(_ animated: Bool) {

super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: animated)

}

Present another UIViewController (e.g., a web view) modally. Dismiss the presented view controller.

Observe that upon returning to HomeViewController, the navigation bar is visible with increased height and lacks expected content.

Expected Behavior:

The navigation bar should remain hidden upon returning to HomeViewController, maintaining the state it had prior to presenting the modal view controller.

Actual Behavior:

Upon dismissing the modal view controller, the navigation bar becomes visible with an unexpected height and lacks content, leading to a disrupted user interface.

Additional Observations:

This issue is specific to iOS 18; it does not occur in iOS 17 or earlier versions. The problem seems to stem from setting the navigation bar to be visible in the viewWillDisappear method, as shown below: override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) navigationController?.setNavigationBarHidden(false, animated: animated) }

Removing or modifying this line mitigates the issue, suggesting a change in the view controller lifecycle behavior in iOS 18.

Request for Clarification:

Is this change in behavior intentional in iOS 18, or is it a regression? Understanding whether this is a new standard or a bug will help in implementing appropriate solutions.

Workaround:

As a temporary measure, I've adjusted the navigation bar visibility settings to avoid changing its state in viewWillDisappear, instead managing it in viewWillAppear or viewDidAppear.

References:

Similar issues have been discussed in the Apple Developer Forums: iPad OS 18 UINavigationBar display incorrectly

Unexpected UINavigationBar Behavior During View Transitions in iOS 18
 
 
Q