Somebody kindly responded to my post on the Apple Dev forum. I have successfully implemented a solution using a container view controller with a portrait and landscape child view controller(s). Works fine.
Swapping ViewController before displaying UINavigationController
-
01-07-2022 - |
문제
I am confused.. I have implemented two separate UIViewControllers - one main VC which is for portrait mode (PortraitVC), and one for landscape mode (LandScapeVC). This is following Apple's "Alternate Views" example in the documentation.
- I display PortraitVC
- I tap a button which displays a UINavigationController, onto which is pushed a UITableViewController
- I rotate the UITableViewController to landscape orientation
- I press 'Done' to pop the UITableViewController and UINavigationController
- BUT.. in my hierarchy, I then see the PortraitVC when my device is still in landscape orientation
What I want to do is somehow remove the PortraitVC from the hierarchy and replace with LandscapeVC so when the UINavigationController dismisses, it animates back to LandscapeVC instead.
How do I replace PortraitVC with LandscapeVC prior to dismissing the UINavigationController please?
Note my root view controller is either the PortraitVC or LandscapeVC which is a custom display - so I don't derive these from UINavigationController. Its only when I tap an image on my root view controller (e.g. setttings button) that I want to start a chain of drill-down UITableViewControllers and need the UINavigationController to take care of "Back" buttons etc.
해결책