When trying to test the Back button on a view controller, I hit an issue in that UIViewController.loadFromStoryboard(identifier: storyboardIdentifier, forNavigation: true) worked for embedding my view in a navigation controller, but I also needed to have a previous view controller in the stack.
My workaround ended up looking like:
let viewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(identifier: storyboardIdentifier)
(viewController as? NoteDetailViewController)?.note = note
let navController = UINavigationController(rootViewController: UIViewController())
navController.loadForTesting()
navController.pushViewController(viewController, animated: false)
RunLoop.current.singlePass()
There could be extra benefits if we could define what ViewControllers we wanted in the stack. If I could do that, then I could also test navigation backwards and that things function correctly in that scenario.
When trying to test the Back button on a view controller, I hit an issue in that
UIViewController.loadFromStoryboard(identifier: storyboardIdentifier, forNavigation: true)worked for embedding my view in a navigation controller, but I also needed to have a previous view controller in the stack.My workaround ended up looking like:
There could be extra benefits if we could define what ViewControllers we wanted in the stack. If I could do that, then I could also test navigation backwards and that things function correctly in that scenario.