UIViewControllerRepresentable
Embedding full UIKit view controllers like UIImagePickerController in SwiftUI.
What is UIViewControllerRepresentable?
Like UIViewRepresentable but wraps a full UIViewController for use inside SwiftUI.
struct ImagePickerView: UIViewControllerRepresentable {
@Binding var image: UIImage?
}makeUIViewController
Create and configure the UIKit view controller. Called once when SwiftUI first renders the representable.
func makeUIViewController(context: Context) -> UIImagePickerController {
let vc = UIImagePickerController()
vc.delegate = context.coordinator
return vc
}