我正在开发一个应用程序,该应用程序具有从其他云资源导入音频文件的功能,这些资源提供UIDocumentPickerViewControllerExtenstion来选择文件,但是左上方有位置按钮,我想删除它。
下面是我的代码:
let menupicker = UIDocumentMenuViewController(documentTypes: [kUTTypeAudio as String], in: .import)
menupicker.delegate = self
self.present(menupicker, animated: true, completion: nil)
func documentMenu(_ documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) {
documentPicker.delegate = self
documentPicker.navigationItem.leftBarButtonItem = nil
self.present(documentPicker, animated: true) {
documentPicker.navigationItem.leftBarButtonItem = nil
documentPicker.navigationItem.backBarButtonItem = nil
documentPicker.navigationItem.hidesBackButton = true
}
}
最佳答案
我正在寻找相同的解决方案,但不能。据我了解,这是不可能的。
如果循环遍历UIDocumentPickerViewController,则实际上它具有类型为“_UIResilientRemoteViewContainerViewController”的子视图控制器。
let picker = UIDocumentPickerViewController(documentTypes: supportDocTypes, in: .import)
picker.delegate = self
present(picker, animated: true) {
print(picker.childViewControllers) // you will get something like this: [<_UIResilientRemoteViewContainerViewController: 0x102e956c0>]
}
这是无法访问的,但是我们可以通过循环访问它来访问它,最终您将获得一些其他 private 组件,例如_RemoteView。
关于ios - UIDocumentPickerViewController-隐藏位置按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45438734/