0

I am want to navigate from UIKIT view controller to SwiftUI screen.

On button Tap in UIVIewcontroller

-(IBAction)buttonTap {
    let SwiftUIController = UIHostingController(rootView: swiftUIScreen())
    navigationController?.pushViewController(SwiftUIController, animated: true)
}

SwiftUI screen look something like this:

var body: some View {
    NavigationView {
        SwiftViewController()
    }
}

I am trying to push another SwiftUI screen from UIView controller same code is working in iOS 16 but not working in iOS15.5 Please check

IOSDev
  • 205
  • 2
  • 10
  • You have both a `NavigationView` in SwiftUI _and_ a `UINavigationController` in UIKit? – jnpdx Jul 19 '23 at 20:38
  • Yes to navigation from UIKIT i am using UINavigationController – IOSDev Jul 19 '23 at 21:06
  • But you _also_ have a `NavigationView`. Normally you use _either_ UIKit or SwiftUI navigation. Not _both_ – jnpdx Jul 19 '23 at 21:23
  • @jnpdx what if the project i am working on have SwiftUI class and also UIKIT class both ? – IOSDev Jul 21 '23 at 19:47
  • You should only have _one_ navigation system. Either SwiftUI or UIKit. If the former, use `NavigationView` and `UIViewControllerRepresentable`. If in UIKit, use `UINavigationController` and push `UIHostingController`s to it – jnpdx Jul 21 '23 at 20:05

0 Answers0