Skip to content

Would like to be able to add previous screens to Navigation Stack #9

@Richard-Gist

Description

@Richard-Gist

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions