Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在单击CPDashboardController中的CPDashboardButton后在CarPlay Dashboard中启动应用程序_Ios_Swift_Xcode_Scenekit_Carplay - Fatal编程技术网

Ios 如何在单击CPDashboardController中的CPDashboardButton后在CarPlay Dashboard中启动应用程序

Ios 如何在单击CPDashboardController中的CPDashboardButton后在CarPlay Dashboard中启动应用程序,ios,swift,xcode,scenekit,carplay,Ios,Swift,Xcode,Scenekit,Carplay,我有导航应用程序,现在我正在开发CarPlay Dashboard。单击CPDashboard中的按钮后无法启动InterfaceController 我的按钮代码: let searchButton = CPDashboardButton(titleVariants: ["Find"], subtitleVariants: ["place"], image: searchImage) { [weak self] (_) in

我有导航应用程序,现在我正在开发CarPlay Dashboard。单击CPDashboard中的按钮后无法启动InterfaceController

我的按钮代码:

let searchButton = CPDashboardButton(titleVariants: ["Find"], subtitleVariants: ["place"], image: searchImage) { [weak self] (_) in
                self?.openSearchView()
            }
点击按钮后,将调用func openSearchView(),但视图仍保留在仪表板中


文档中没有任何信息,我们如何在视图(界面控制器仪表板控制器)之间切换?

不确定这是正确的方法,但没有提到这一点,甚至官方示例应用程序也没有这样做。但您可以通过在dashboardScene上调用
open(uz,options:,completionHandler)
来实现它

像这样

dashboardController.shortcutButtons = [CPDashboardButton(titleVariants: ["Find"], subtitleVariants: ["place"], image: searchImage, handler: { _ in
    guard let url = URL(string: "your.app.scheme://whatever/wherever") else { return }
    templateApplicationDashboardScene.open(url, options: nil, completionHandler: nil)
})]

这将打开主应用程序,并在主carplay场景中调用
open(u,urlContexts:)
,您可以处理该url并做出相应的反应,就像打开搜索ar一样。

就是这样!我三周前做的,忘了在这里写答案。谢谢你的帮助;)