So I followed Apples video on how to make a basic CarPlay app. But I am getting a blank screen instead of a list view.
How can I make a simple list view using the CPTemplate method?
import Foundation
import CarPlay
class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate {
var interfactController: CPInterfaceController?
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController) {
let item = CPListItem(text: "hello", detailText: "This works")
let jazz = CPListItem(text: "Jazz", detailText: "How about some smooth jazz.")
let listTemplate = CPListTemplate(title: "TEST", sections: [CPListSection(items:[item,jazz])])
print("HUGE TEST TO SEE IF THIS IS RUNNING")
self.interfactController?.setRootTemplate(listTemplate, animated: false)
}
}
I know it runs as I get HUGE TEST TO SEE IF THIS IS RUNNING in console log. Just the next line does not run/load.
Your interfaceController is nil. You can initialize it with the interfaceController from the delegate method.
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController) {
self.interfactController = interfaceController
//your code to load template
}