Search code examples
iosswiftcarplay

Swift - CarPlay - CPListTemplates do not show title


I am implementing car play for my iOS app using swift

When creating the Tab Bar Template (CPTabBarTemplate) I am creating it using 4 CPListTemplate items

let listTemplate = CPListTemplate(title: "Hooping", sections: [hoopingSec])
    let listTemplate1 = CPListTemplate(title: "Rap", sections: [rapSec])
    let listTemplate2 = CPListTemplate(title: "RnB", sections: [RnBSec])
    let listTemplate3 = CPListTemplate(title: "All", sections: [allSec])
    
    
    let theTab = CPTabBarTemplate(templates: [listTemplate, listTemplate1, listTemplate2, listTemplate3])`

The issue I am having is that when I run the app on CarPlay in my car or on the simulator the titles for the tabs all say "more" and the image is three dots "..."

Does anyone know what is going?

I created the templates with the steps above. However when adding the template to the root I used the code below

`self.interfaceController?.delegate = self
    
    listTemplate.tabTitle = "Hooping"
    listTemplate1.tabTitle = "Rap"
    listTemplate2.tabTitle = "RnB"
    listTemplate3.tabTitle = "All"
    
    theTab.updateTemplates([listTemplate, listTemplate1, listTemplate2, listTemplate3])

    self.interfaceController?.setRootTemplate(theTab, animated: true, completion: nil)
    
    self.interfaceController?.pushTemplate(listTemplate3, animated: true, completion: nil)
    self.interfaceController?.pushTemplate(listTemplate2, animated: true, completion: nil)
    self.interfaceController?.pushTemplate(listTemplate1, animated: true, completion: nil)
    self.interfaceController?.pushTemplate(listTemplate, animated: true, completion: nil)`

Ive tried it with the pushTemplates and without. I also tried without manually setting the tabTitles


Solution

  • I was able to reproduce your issue using your code.

    I then compared your code with my working app and the difference I noticed is that you are not setting tabImage.

    Once I provided a value to the tabImage property the tabs had the correct title.

    It doesn't seem to be documented, but if your tab doesn't include a valid image, it is assumed to be the "more" tab that allows the user to select from a list of tabs that don't fit on screen.