【发布时间】:2020-02-07 20:32:52
【问题描述】:
我刚刚开始尝试使用 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 之前显示 DocumentViewController,尽管 Apple 要求 DocumentBrowserViewController 是初始视图控制器。我通过更改应用程序委托来做到这一点:
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 mac-catalyst uidocumentbrowserviewcontroller