I have a SwiftUI NavigationView
in which I push to a to UIViewControllerRepresentable
conforming UIViewController
. The navigation view naturally adds its back button. However, all navigation bar buttons that I set in the pushed-to view controller are also gone.
The code for adding the item is nothing new and works just fine if I push from a good ol' UIKit View Controller:
navigationItem.rightBarButtonItem = UIBarButtonItem(image: searchImage, style: .plain, target: self, action: #selector(filterItemTapped(button:)))
My theory is that they haven't wired up bridging between NavigationView and UIViewController's navigation items, but maybe somebody knows a workaround.
UIViewControllerRelatable
is aView
inside aSwiftUI
app. As is yourNavigationView
. But you make it sound like you want some kind of navigation bar in yourUIViewController
, as inUIKit
? If so, maybe you need to rethink something - maybe even the reverse (put your SwiftUIView
into yourUIKit
app). – dfdUIViewController
, that's moreCombine
thanSwiftUI
(but yeah, it's both). But if you want to push aNavigationBar
, which is aView
, then yes you need to do the reverse - make aUIKit
app and import the views. – dfd