【问题标题】:iOS 13 performActionFor shortcutItem doesn't get called in SceneDelegate now on launch, but does after app launches. Why?iOS 13 performActionFor shortcutItem 现在在启动时不会在 SceneDelegate 中调用,但在应用启动后会调用。为什么?
【发布时间】:2020-01-15 18:40:35
【问题描述】:

performActionFor shortcutItem 如果应用程序已经启动,则会在我的 SceneDelegate 中调用,但如果应用程序实际上从快捷方式项启动,则不会调用它。这是为什么呢?

【问题讨论】:

    标签: ios cocoa-touch ios13 uiscene uiscenedelegate


    【解决方案1】:

    当从快捷项目启动应用程序时(并且当后台没有应用程序实例时),您可以从sceneDelegate中的willConnectTo函数获取ShortcutItems

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    if let shortcutItems = connectionOptions.shortcutItem{
        }
    }
    

    【讨论】:

    • 嘿,这就是它的全部吗?当应用程序通过 func windowScene(.. performActionForshortcutItem..) 运行时,我设置并运行了快速操作,但由于在应用程序未启动时这不起作用,我正在寻找一种修复它的方法。而且我似乎无法得到你建议的工作。我添加了 if let shortcutItems = connectionOptions.shortcutItem{ UIApplication.shared.windows.first?.rootViewController?.alert(title:shortcutItems.debugDescription) } 或尝试将值保存到用户默认值以对其进行测试,但它什么也不做。有什么线索吗?
    猜你喜欢
    • 2016-07-03
    • 1970-01-01
    • 2020-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多