CPListTemplate
A template that displays and manages a list of items.
Declaration
@MainActor class CPListTemplateOverview
Use the list template to display a list of items, grouped into one or more sections. When the user selects an item, CarPlay invokes Siri or a custom handler that you provide, depending on the type of list item. If your list displays hierarchical data, use the handler to add templates to the navigation hierarchy.
To create a list template, call the init(title:sections:) method and provide an array of CPListSection objects. At runtime, use maximumSectionCount to determine the maximum number of sections your list can display. Use maximumItemCount to determine the maximum number of items across all sections that your list can display.
Each section contains an array of list items — objects that conform to either the CPListTemplateItem or the CPSelectableListItem protocol. CarPlay provides three concrete implementations of these protocols:
- CPListItem
A generic, selectable list item.
- CPListImageRowItem
A list item that displays a series of images.
- CPMessageListItem
A list item that represents a conversation or contact.
To display the list, call your interface controller’s pushTemplate(_:animated:completion:) method, passing in the list template to add it to your navigation hierarchy. Alternatively, add the template as a tab in your CPTabBarTemplate.
Integrating Siri Into Your Template App
For audio and communication apps, CarPlay provides an assistant cell to let users interact with your app using Siri_._
[Image]
To enable the assistant cell, your app must support specific Siri intents:
To play audio, audio apps must support INPlayMediaIntent.
To make phone calls, communication apps must support INStartCallIntent.
To enable the assistant cell in your list template, use init(title:sections:assistantCellConfiguration:) and provide the required configuration. For more information, see CPAssistantCellConfiguration. CarPlay automatically updates your app’s interface if you change the template’s assistantCellConfiguration property.
Topics
Creating a List Template
Managing Sections
Managing the Assistant Cell
Managing an Empty List
Getting Supplementary Information
Responding to List Events
Initializers
init(title:listHeader:sections:assistantCellConfiguration:)init(title:sections:assistantCellConfiguration:headerGridButtons:)