HOW I SOLVED FOR ME, hope this helps:
**Why it was happening: **
My app was going from a UIView that was inside a nav controller to a modal with no nav bar to a uiview again:
1.NAV BAR UIVIEW ---> 2. NO NAV BAR MODAL VIEW -> 3. UI VIEW
For some reason the final destination screen was treated like it was outside of the navigation controller group, because the previous screen was a modal that hid the nav bar. There are loads of overcomplicated-solutions out there about that part but I found the below combination fixed all issues. In brief, it's got to do with segues/presenting screen AND the "Presentation" setting in attributes in storyboard in the screen which followed the modal. HARD TO EXPLAIN BUT CHECK THE SOLUTION IN DIFFERENT COMBINATIONS TO SEE IF IT WORKS FOR YOU - Note my error message contained [Presentation] at the beginning which made me realise what might be happening, your error message may have something different but check for that word in the storyboard right hand pane.
**How I fixed it: **
If your app is using a navigation controller and you have a modal view (or any other view) that hides the nav bar:
A. Put this in your modal view :
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: animated)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
}
B. then put this in the view that comes directly after the modal view i.e. the one you present or segue to afterwards
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
}
C. then, in storyboard, select the view that comes after the modal view and in the right hand pane, under attributes inspector --> view controller section: presentation -> select "Full Screen"