Hide navigation bar in iOS16 + xcode 14 beta not working

Viewed 1097

We use Firebase's Crashlytics and in the last 2 days we've seen a spike in crashes with navigationController?.setNavigationBarHidden on iOS 16 devices. I was able to reproduce the crash after installing Xcode 14.5

I have a view controller (VC1) embedded in a navigational controller with the following code in

override func viewWillDisappear(_ animated: Bool) {
  super.viewWillDisappear(animated)
  ...
  navigationController?.setNavigationBarHidden(false, animated: animated) // crash here
}

and after I push another view controller (VC2) using the following code

navigationController?.pushViewController(vc, animated: true)

the app crashes with the following error message

2022-08-10 15:07:04.866752-0700 autolist-dev[22341:3295980] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to activate constraint with anchors <NSLayoutXAxisAnchor:0x600001a9d740 "_UITAMICAdaptorView:0x7fd6c70ddbe0.leading"> and <NSLayoutXAxisAnchor:0x600001466680 "_UINavigationBarTitleControl:0x7fd6c70dcb80.leading"> because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That's illegal.'

It doesn't immediately crash the first time VC2 is pushed. After I go back to VC1 and then push VC2 again then the app crashes.

Does anyone have any ideas on how to resolve this? I can't seem to find anyone else having a similar issue

0 Answers
Related