ios - UIDocumentPickerViewController - 隐藏位置按钮

标签 ios swift uidocumentpickervc

我正在开发一个应用程序,它能够从其他提供 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
    }
}

enter image description here

最佳答案

我正在寻找相同的解决方案,但找不到。以我的理解,这是不可能的。 如果您遍历 UIDocumentPickerViewController,它实际上有一个类型为“_UIResilientRemoteViewContainerViewController”的 subview Controller

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/

相关文章:

xcode - UIDocumentPickerViewController 取消父 View Controller

ios - 是否有可能永久访问从 DocumentPicker 导入的文件?

ios - swift 2 将 int 转换为 numberFromString 作为 String

ios - 在 iOS 的 Quickblox 中使用聊天功能

iphone - Objective C/iPhone - Date Time Picker 如何格式化它的日期(例如 strip YYYY)以及如何检索这些格式?

swift - Firebase 身份验证获取用户个人资料

ios - 无法生成与拉动刷新指示器相同的事件指示器

ios - 应用程序在没有方法的情况下运行良好,但我认为它需要方法才能正常运行

ios - 委托(delegate)/协议(protocol)将数据从一个 View Controller 传递到另一个

ios - 如果不是 Apple Developer Program 的成员,可以使用 Document Picker 吗?