gpt4 book ai didi

ios - 使用在后台运行的应用程序打开文件

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:03:10 25 4
gpt4 key购买 nike

我正在创建一个应用程序,当我在该文件的“打开方式” 对话框中点击我的应用程序图标时,它应该能够打开该文件。为了做到这一点,我假设我可以通过 AppDelegate 中的 application(_:didFinishLaunchingWithOptions:) 或 application(_:willFinishLaunchingWithOptions:) 获取文件数据,从那里我可以获取外部文件的 url。当应用程序启动时。

但是,当我在文件的“打开方式” 对话框中点击其图标时,我的应用程序应该已经在后台运行。因此,application(_:didFinishLaunchingWithOptions:) 或 application(_:willFinishLaunchingWithOptions:) 永远不会被调用,因为在这种情况下应用程序将从后台返回,因此,只有函数 applicationWillEnterForeground(_ :)AppDelegate 中被调用。

有什么办法可以解决这个问题吗? (抱歉我的英语不好)

最佳答案

查看 application(_:open:options:)。当您的应用程序已经运行时会调用此方法,而不是当另一个应用程序想要打开您的应用程序时调用 application(_:didFinishLaunchingWithOptions:)

请在此处查看 Apple 文档:https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application

关于ios - 使用在后台运行的应用程序打开文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50125507/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com