I made a class named ViewController which is an UICollectionViewController. I wanted to implement it in ContentView which is a View.
I tried using UIViewControllerRepresentable protocol, but I got error. In addition, I went through the SwiftUI tutorial made by Apple, but could not solve the problem.
import SwiftUI
struct ViewControllerWrapper: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> ViewController {
let vc = ViewController()
return vc
}
func updateUIViewController(_ uiViewController: ViewController, context: Context) {
}
}
struct ContentView : View {
var body: some View {
ViewControllerWrapper()
}
}