0

我在 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 外接显示器中。

4

1 回答 1

0

您无法直接访问 carplay 屏幕,carplay 使用 CPInterfaceController 类管理所有内容,该类能够显示所谓的模板(例如 CPListTemplate 和其他一些模板)。您在屏幕上绘图的能力几乎仅限于在 CPMapContentWindow 中绘制地图。我建议您首先从这里开始阅读 Apple 文档: https ://developer.apple.com/carplay/documentation/CarPlay-Navigation-App-Programming-Guide.pdf

不要忘记设置正确的应用程序权限和 carplay 权利,否则它根本不起作用,它可能不会告诉你原因。

最后一句话,Carplay 框架只适用于导航应用程序。其他一切都需要很多变通方法,更不用说它永远不会通过应用程序审查。希望这可以帮助

于 2018-12-21T15:37:26.140 回答