I am working to implement some SwiftUI content into my existing app. I currently have a UIViewController, which hosts a MTKView for camera preview.
I have created a new SwiftUI view, which is now my root view, as set in my SceneDelegate.swift
file. The SwiftUI view loads at launch, as expected. Now, I would like to create a segue in which, when a user taps on a row in my List, it will segue, full-screen to my existing UIViewController. Here is how I'm calling that;
var body: some View {
VStack {
NavigationView {
List(sessionTypes) { session in
NavigationLink(destination: CameraControllerWrapper()) {
SessionRow(session: session)
.frame(height: 40.0)
}
}
.navigationBarTitle(Text("Camera Types"))
}
}
}
For posterity, here is my CameraControllerWrapper
UIViewControllerRepresentable;
struct CameraControllerWrapper: UIViewControllerRepresentable {
typealias UIViewControllerType = CameraController
func makeUIViewController(context: UIViewControllerRepresentableContext<CameraControllerWrapper>) -> CameraControllerWrapper.UIViewControllerType {
return CameraController()
}
func updateUIViewController(_ uiViewController: CameraControllerWrapper.UIViewControllerType, context: UIViewControllerRepresentableContext<CameraControllerWrapper>) {
//
}
}
While this "works," my app crashes as soon as the CameraController is called, as it seems any of my IBOutlets cannot be found. CameraController is a UIViewController built in the storyboard.
Storyboard
app, that you (2) made theMainViewController
root view be aSwiftUI
view, and (3) put aNavigationView
in this root view and (4) navigates to aUIViewControllerRepresentable
that has (5)IBOutlets
defined in it? If something in this chain is wrong, please correct me. – Audrey