我一直在尝试在一个新的应用程序中实现照片选择功能。我目前的方法是使用一个嵌入在UIViewControllerRepresentable中的PHPickerViewController来在SwiftUI视图中显示。
这是我的makeUIViewController函数。
func makeUIViewController(context: Context) -> PHPickerViewController {
var configuration = PHPickerConfiguration()
configuration.filter = filter
configuration.selectionLimit = limit
let controller = PHPickerViewController(configuration: configuration)
controller.delegate = context.coordinator
return controller
}
这段代码位于一个名为PhotoPicker
的结构体内:
struct PhotoPicker: UIViewControllerRepresentable {
我想隐藏的部分是:
![enter image description here](https://istack.dev59.com/v63RZ.webp)
我尝试了很多不同的方法,包括在makeUIViewController中创建控制器时尝试设置选项。例如这些选项:
controller.navigationController?.setToolbarHidden(true, animated: false)
controller.navigationController?.setNavigationBarHidden(true, animated: false)
我也尝试在我的SwiftUI主体中调用视图修改器:
PhotoPicker(filter: .images, limit: 1) { (results) in
}
.navigationBarTitle("")
.navigationBarHidden(true)
.statusBar(hidden: true)
.navigationBarBackButtonHidden(true)
但是,再次尝试了所有方法似乎都没有用。因此我来这里问,因为看起来我已经尝试了所有方法都不起作用...