我在Xcode中创建了一个新的应用程序,并在AppDelegate文件中添加了以下代码
func updateCarWindow()
{
guard let screen = UIScreen.screens.first(where: { $0.traitCollection.userInterfaceIdiom == .carPlay })
else
{
// CarPlay is not connected
self.carWindow = nil;
return
}
// CarPlay is connected
let carWindow = UIWindow(frame: screen.bounds)
carWindow.screen = screen
carWindow.makeKeyAndVisible()
carWindow.rootViewController = CarViewController(nibName: nil, bundle: nil)
self.carWindow = carWindow
}并在函数应用中调用该函数。应用程序未显示在CarPlay外部显示器中。
发布于 2018-12-21 23:37:26
您不能直接访问carplay屏幕,carplay使用能够显示所谓模板(如CPListTemplate和少数其他模板)的CPInterfaceController类来管理一切。您在屏幕上绘图的能力很大程度上仅限于在CPMapContentWindow中绘制地图。我建议你先从这里开始阅读苹果文档:https://developer.apple.com/carplay/documentation/CarPlay-Navigation-App-Programming-Guide.pdf
别忘了设置正确的应用权限和carplay权限,否则它根本不会工作,也可能不会告诉你原因。
最后一句话,Carplay框架应该只适用于导航应用程序。其他任何事情都需要很多变通,更不用说它永远不会通过应用程序审查。希望这能有所帮助
https://stackoverflow.com/questions/53479793
复制相似问题