Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在基于UIDocumentBrowserViewController的应用程序中打开多个文档_Ios_Mdi_Document Based - Fatal编程技术网

Ios 在基于UIDocumentBrowserViewController的应用程序中打开多个文档

Ios 在基于UIDocumentBrowserViewController的应用程序中打开多个文档,ios,mdi,document-based,Ios,Mdi,Document Based,苹果的文档很少涉及基于UIDocumentBrowserViewController的应用程序,这些应用程序希望支持同时打开多个文档 我希望启用此功能,以便用户可以轻松地在两个或多个文档之间复制/粘贴,而无需退出到文档浏览器,这在iOS上不是一种流畅的体验 除了对房产的简要描述外,我什么也找不到 对于单个文档视图,苹果建议使用模式视图,但没有说明其他内容 问题 实现多个打开文档的体验和UI的推荐方法是什么(如果有) 用户是否有办法打开一组文档,然后在打开现有文档的同时打开另一个文档 有没有实现这

苹果的文档很少涉及基于
UIDocumentBrowserViewController
的应用程序,这些应用程序希望支持同时打开多个文档

我希望启用此功能,以便用户可以轻松地在两个或多个文档之间复制/粘贴,而无需退出到文档浏览器,这在iOS上不是一种流畅的体验

除了对房产的简要描述外,我什么也找不到

对于单个文档视图,苹果建议使用模式视图,但没有说明其他内容

问题

  • 实现多个打开文档的体验和UI的推荐方法是什么(如果有)
  • 用户是否有办法打开一组文档,然后在打开现有文档的同时打开另一个文档
  • 有没有实现这种体验的应用程序

  • 我是一个相对较新的iOS开发人员,所以对所有这些都要谨慎对待

    以下几点对我很有用:

  • 将allowsPickingMultipleItems设置为true
  • 创建一个可接受
    URL
    输入的ViewController,以及另一个可接受
    [URL]
    输入的ViewController。然后,这些ViewController必须在屏幕上显示与URL关联的文档。
    • 可以处理一个或多个文档的单个ViewController也可以工作
  • documentBrowser(:,didPickDocumentURLs:)
    中,检查传入的
    URL
    数量,并显示上述其中一个ViewController(视情况而定)
  • 例如:

    class DocumentBrowserViewController: UIDocumentBrowserViewController, UIDocumentBrowserViewControllerDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        delegate = self
        allowsDocumentCreation = false
        allowsPickingMultipleItems = true
    
        // -snip-
    
    }
    
    // MARK: UIDocumentBrowserViewControllerDelegate
    
    // -snip-
    
    func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentURLs documentURLs: [URL]) {
        if documentURLs.count < 1 {
            return
        } else if documentURLs.count == 1 {
            presentDocument(at: documentURLs[0])
        } else {
            presentDocuments(at: documentURLs)
        }
    }
    
    // -snip-
    
    // MARK: Document Presentation
    
    func presentDocument(at documentURL: URL) {
        // present one document
    
        // example:
        // let vc = SingleDocumentViewController()
        // vc.documentURL = documentURL
        // present(vc, animated: true, completion: nil)
    }
    func presentDocuments(at documentURLs: [URL] {
        // present multiple documents
    
        // example:
        // let vc = MultipleDocumentViewController()
        // vc.documentURLs = documentURLs
        // present(vc, animated: true, completion: nil)
    }
    }
    
    类DocumentBrowserViewController:UIDocumentBrowserViewController,UIDocumentBrowserViewControllerDelegate{
    重写func viewDidLoad(){
    super.viewDidLoad()
    代表=自我
    allowsDocumentCreation=false
    allowsPickingMultipleItems=true
    //-剪断-
    }
    //标记:UIDocumentBrowserveWControllerDelegate
    //-剪断-
    func documentBrowser(u控制器:UIDocumentBrowserViewController,didpickdocumenturl:[URL]){
    如果documentURLs.count<1{
    返回
    }如果documentURLs.count==1,则为else{
    presentDocument(位于:documentURLs[0])
    }否则{
    presentDocuments(位于:documentURLs)
    }
    }
    //-剪断-
    //标记:文档演示
    func presentDocument(位于documentURL:URL){
    //提交一份文件
    //例如:
    //设vc=SingleDocumentViewController()
    //vc.documentURL=documentURL
    //当前(vc,动画:真,完成:无)
    }
    func presentDocuments(位于DocumentURL:[URL]{
    //出示多份文件
    //例如:
    //设vc=MultipleDocumentViewController()
    //vc.documentURLs=documentURLs
    //当前(vc,动画:真,完成:无)
    }
    }
    
    要回答您的其他问题,请执行以下操作:

  • 我不确定建议如何实现此功能
  • 我认为打开一个,然后打开另一个文档可能更适合
  • 我不知道有任何应用程序实现了这种多文档体验。但是,通过反复试验,我确实知道,文档浏览器看起来与通常一样,但在右上角有一个“选择”按钮。按下此按钮后,用户可以选择要打开的文档和文件夹,或“全选”
  • 一些警告:

    • 如果选择了文件夹,且该文件夹不在应用程序自己的目录中,则应用程序将无权访问文件夹中的文档
    注:
    documentBrowser(:,didpickdocumenturl:)
    将被重命名为
    documentBrowser(:,didPickDocumentsAt:)
    我是一个相对较新的iOS开发人员,所以对这一切都要谨慎对待

    以下几点对我很有用:

  • 将allowsPickingMultipleItems设置为true
  • 创建一个可接受
    URL
    输入的ViewController,以及另一个可接受
    [URL]
    输入的ViewController。然后,这些ViewController必须在屏幕上显示与URL关联的文档。
    • 可以处理一个或多个文档的单个ViewController也可以工作
  • documentBrowser(:,didPickDocumentURLs:)
    中,检查传入的
    URL
    数量,并显示上述其中一个ViewController(视情况而定)
  • 例如:

    class DocumentBrowserViewController: UIDocumentBrowserViewController, UIDocumentBrowserViewControllerDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        delegate = self
        allowsDocumentCreation = false
        allowsPickingMultipleItems = true
    
        // -snip-
    
    }
    
    // MARK: UIDocumentBrowserViewControllerDelegate
    
    // -snip-
    
    func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentURLs documentURLs: [URL]) {
        if documentURLs.count < 1 {
            return
        } else if documentURLs.count == 1 {
            presentDocument(at: documentURLs[0])
        } else {
            presentDocuments(at: documentURLs)
        }
    }
    
    // -snip-
    
    // MARK: Document Presentation
    
    func presentDocument(at documentURL: URL) {
        // present one document
    
        // example:
        // let vc = SingleDocumentViewController()
        // vc.documentURL = documentURL
        // present(vc, animated: true, completion: nil)
    }
    func presentDocuments(at documentURLs: [URL] {
        // present multiple documents
    
        // example:
        // let vc = MultipleDocumentViewController()
        // vc.documentURLs = documentURLs
        // present(vc, animated: true, completion: nil)
    }
    }
    
    类DocumentBrowserViewController:UIDocumentBrowserViewController,UIDocumentBrowserViewControllerDelegate{
    重写func viewDidLoad(){
    super.viewDidLoad()
    代表=自我
    allowsDocumentCreation=false
    allowsPickingMultipleItems=true
    //-剪断-
    }
    //标记:UIDocumentBrowserveWControllerDelegate
    //-剪断-
    func documentBrowser(u控制器:UIDocumentBrowserViewController,didpickdocumenturl:[URL]){
    如果documentURLs.count<1{
    返回
    }如果documentURLs.count==1,则为else{
    presentDocument(位于:documentURLs[0])
    }否则{
    presentDocuments(位于:documentURLs)
    }
    }
    //-剪断-
    //标记:文档演示
    func presentDocument(位于documentURL:URL){
    //提交一份文件
    //例如:
    //设vc=SingleDocumentViewController()
    //vc.documentURL=documentURL
    //当前(vc,动画:真,完成:无)
    }
    func presentDocuments(位于DocumentURL:[URL]{
    //出示多份文件
    //例如:
    //设vc=MultipleDocumentViewController()
    //vc.documentURLs=documentURLs
    //当前(vc,动画:真,完成:无)
    }
    }
    
    要回答您的其他问题,请执行以下操作:

  • 我不确定建议如何实现此功能
  • 我认为打开一个,然后打开另一个文档可能更适合
  • 我不知道有任何应用程序实现了这种多文档体验。但是,通过反复试验,我确实知道,文档浏览器看起来与通常一样,但在右上角有一个“选择”按钮。按下此按钮后,用户可以选择要打开的文档和文件夹,或“全选”<