Chapter 24: Scene Coordinator

I’m using the scene coordinator in an app but theres an issue when push. When I push another viewController on the stack it works but if click back and try to push the same view controller I receive an error.

The error goes back to SceneCoordinator transition function and the message is that you can’t push a viewController if there’s no navigationController.

2 Likes

@fpillet Can you please help with this when you get a chance? Thank you - much appreciated! :]

I am having the same problem. The SceneCoordinator doesn’t seem to have any knowledge about when the navigation controller back button is tapped (or an edge swipe back) which leaves the currentViewController property pointing to the wrong VC.

@fpillet Do you have any feedback about this? Thank you - much appreciated! :]

@fuadadetoro @robmaceachern
You need to make the Scene Coordinator a UINavigationControllerDelegate then implement the func navigationController(UINavigationController, didShow: UIViewController, animated: Bool) (or the willShow equivalent) callback.

Once you’ve done that, you can update the currentViewController with the new one and you should be all set.

We had to keep the code a reasonable size so the implementation you see in the book does not cover all cases. Setting your coordinator as a UINavigationControllerDelegate will help you cover more scenarii!

Hope this helps
Florent

This topic was automatically closed after 166 days. New replies are no longer allowed.