ios - 在 AppDelegate.swift 中没有调用 userActivity 函数
问题描述
当我点击 Core Spotlight 搜索的结果时,应用程序会启动,但AppDelegate.swift
不会调用其中的函数:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
print("called")
}
它包含用于导航到特定视图控制器和加载数据的逻辑。
这里的一些人似乎建议使用SceneDelegate.swift
:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
print("called"
}
但也不会从 Core Spotlight 中调用。
似乎被调用的唯一函数是:
func sceneDidBecomeActive(_ scene: UIScene) {}
func sceneWillEnterForeground(_ scene: UIScene) {}
in SceneDelegate.swift
,但没有所需的userActivity
参数。
解决方案
推荐阅读
- javascript - 对一组对象执行一些检查,如果其中一个条件匹配,则停止批量请求
- reactjs - React history.push 自动重定向
- image - 如何应用非最大抑制进行角点检测
- c - 哈希表未在 C 中填充
- android - Android BLE 未显示结果
- node.js - “重新安装 nodejs 后出现错误”
- c++ - C++ 导入关键字、模块关键字和导出关键字
- java - BottomNavigationActivity 中的片段变形
- java - 如何为 java jar 文件创建 Windows 安装程序?
- html - top/bottom:[%] 基于父元素的边框而不是高度