发布于 2022-03-23 21:25:07
这可以用UIViewControllerRepresentable来完成,就像.
struct PhotoPicker: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> some UIViewController {
var config = YPImagePickerConfiguration()
YPImagePickerConfiguration.shared = config
let picker = YPImagePicker(configuration: config)
picker.delegate = context.coordinator
return picker
}
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
class Coordinator: NSObject, UINavigationControllerDelegate {
let parent: PhotoPicker
init(_ parent: PhotoPicker) {
self.parent = parent
}
}
}然后这样叫它..。
Text("SomeView")
.sheet(isPresented: $showPhotoPicker) {
PhotoPicker()
}https://stackoverflow.com/questions/70962237
复制相似问题