1

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

6
  • You need to set the tabTitle property of the list template.
    – Paulw11
    Commented Oct 2, 2024 at 10:41
  • @Paulw11 I have done that. Under the line where I set the interfaceController delegate Commented Oct 2, 2024 at 11:34
  • Right. I missed that. Why are you calling pushTemplate with the various list templates? You shouldn't do that.
    – Paulw11
    Commented Oct 3, 2024 at 8:05
  • @Paulw11 I’ve removed those lines but still experiencing the issue Commented Oct 5, 2024 at 3:14
  • I suggest you edit your question to show a minimal reproducible example. For example, add details on theTab
    – Paulw11
    Commented Oct 5, 2024 at 5:51

1 Answer 1

2

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.

1
  • This was the solution. Thank you @Paulw11 Commented Oct 7, 2024 at 14:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.