首页 > 解决方案 > iOS 13 performActionFor shortcutItem 现在在启动时不会在 SceneDelegate 中调用,但在应用启动后会调用。为什么?

问题描述

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

标签: ioscocoa-touchios13uisceneuiscenedelegate

解决方案


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

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

推荐阅读