在Mac Catalyst中使用文档浏览器视图控制器

问题描述 投票:0回答:1

我刚刚开始尝试使用Catalyst。我的应用程序是基于文档浏览器的应用程序。

单击相应的按钮后,确实会启动股票MacOS Finder对话框。当Finder对话框出现时,主应用程序窗口完全消失,除非我在IB中选择将文档浏览器视图控制器显示为“自动”模式。

取消操作确实会带回主窗口。

但是,选择文件将显示空白屏幕,并且没有结果。进行了一些调试后发现,没有文件选择功能被调用,并且我已经实现了所有这些功能:

func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentURLs documentURLs: [URL]) {...}

func documentBrowser(_ controller: UIDocumentBrowserViewController, didImportDocumentAt sourceURL: URL, toDestinationURL destinationURL: URL) {...}

func documentBrowser(_ controller: UIDocumentBrowserViewController, failedToImportDocumentAt documentURL: URL, error: Error?) {...}

Catalyst中是否使用了另一个功能或句柄?我在文档中什么都没找到。

编辑:我应该澄清一下,尽管苹果要求DocumentBrowserViewController是初始视图控制器,但我还是操纵了该应用程序以在DocumentBrowserViewController之前展示DocumentViewController。我通过更改应用程序委托来做到这一点:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

...

// Set the documentViewController to appear first
    self.window = UIWindow(frame: UIScreen.main.bounds)

    let storyboard = UIStoryboard(name: "Main", bundle: nil)

    let initialViewController = storyboard.instantiateViewController(withIdentifier: "main")

    self.window?.rootViewController = initialViewController
    self.window?.makeKeyAndVisible()

    return true
}

解决这个问题仍然没有任何改变。从文档浏览器模板创建的默认项目似乎确实起作用。是什么可以阻止调用这些方法?

swift browser document catalyst uidocumentbrowserviewcontroller
1个回答
1
投票

我也建议实施func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentsAt documentURLs: [URL])

© www.soinside.com 2019 - 2024. All rights reserved.