applicationWillResignActive
sceneWillResignActive
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void)
和
func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void)
任何建议?
仅在应用程序运行时才调用表演方法(在后台0中。如果不是。如果不是在应用程序启动时,则需要检查捷径是否在didfinishlaunchingwithoptions或willfinishlaunchingwithoptions中。快捷方式将在启动项目中。 像这样的东西:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
if let shortcutItem = launchOptions?[UIApplication.LaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem{
handleShortcutItem(shortcutItem)
}
return true
}
对于场景委托您可以使用此代码:
handleShortcutItem