Return to storyboard after segue to UIHostingController

Hi


I have implemented a set of SwiftUI views into an existing app that uses a storyboard. Using a UIHostingController I can navigate to my SwiftUI views perfectly. I am struggling to understand how I return to the storyboard view controller as I don't seem to be able to get a handle to the UIHostingController from within SwiftUI to pop it.


Hopefully someone can help 🙂


Thanks in advance,

Mike.

Replies

Is your SwiftUI view in a NavigationView?

The more I think of it, the more I think my idea is a bad one.

Found this tutorial helpful. Hope it will help you as well.


h ttps://medium.com/@code_cookies/swiftui-embed-swiftui-view-into-the-storyboard-a6fc96e7a0a1


In your case, I would try doing so:

- declare une unwind segue action in the UIViewController

- in SwiftUI view, create a return button

- connect the return button to the exit icon of the SwiftUI view, and select the unwind.