In my CarPlaySceneDelegate.swift, I’ve two tabs:
- The primary tab makes use of a
CPListImageRowItemwith aCPListImageRowItemRowElement. The scroll path is inverted, and the facet button doesn’t operate appropriately. - The second tab makes use of a number of
CPListItemobjects. There aren’t any points: scrolling works within the appropriate path, and the facet button behaves as anticipated.
Steps To Reproduce
- Launch the app.
- Connect with CarPlay.
- Within the first tab, scroll up and down, then use the facet button to navigate.
- Within the second tab, scroll up and down, then use the facet button to navigate.
- As noticed, the scrolling habits is totally different between the 2 tabs.
Code Instance:
import CarPlay
import UIKit
class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate {
var interfaceController: CPInterfaceController?
func templateApplicationScene(
_ templateApplicationScene: CPTemplateApplicationScene,
didConnect interfaceController: CPInterfaceController
) {
self.interfaceController = interfaceController
downloadImageAndSetupTemplates()
}
func templateApplicationScene(
_ templateApplicationScene: CPTemplateApplicationScene,
didDisconnectInterfaceController interfaceController: CPInterfaceController
) {
self.interfaceController = nil
}
personal func downloadImageAndSetupTemplates() {
let urlString = "https://encrypted-tbn0.gstatic.com/photographs?q=tbn:ANd9GcRcYUjd1FYkF04-8Vb7PKI1mGoF2quLPHKjvnR7V4ReZR8UjW-0NJ_kC7q13eISZGoTCLHaDPVbOthhH9QNq-YA0uuSUjfAoB3PPs1aXQ&s=10"
guard let url = URL(string: urlString) else {
setupTemplates(with: UIImage(systemName: "picture")!)
return
}
URLSession.shared.dataTask(with: url) { [weak self] information, _, _ in
let picture: UIImage
if let information = information, let downloaded = UIImage(information: information) {
picture = downloaded
} else {
picture = UIImage(systemName: "picture")!
}
DispatchQueue.major.async {
self?.setupTemplates(with: picture)
}
}.resume()
}
personal func setupTemplates(with picture: UIImage) {
// Tab 1 : un seul CPListImageRowItem avec 12 CPListImageRowItemRowElement
let components: [CPListImageRowItemRowElement] = (1...12).map { index in
CPListImageRowItemRowElement(picture: picture, title: "take a look at (index)", subtitle: nil)
}
let rowItem = CPListImageRowItem(textual content: "Photographs", components: components, allowsMultipleLines: true)
rowItem.listImageRowHandler = { merchandise, elementIndex, completion in
print("tapped factor (elementIndex)")
completion()
}
let tab1Section = CPListSection(objects: [rowItem])
let tab1Template = CPListTemplate(title: "CPListImageRowItemRowElement", sections: [tab1Section])
// Tab 2 : 12 CPListItem simples
let tab2Items: [CPListItem] = (1...12).map { index in
let merchandise = CPListItem(textual content: "Merchandise (index)", detailText: "Element (index)")
merchandise.handler = { _, completion in
print("handler Tab 2")
completion()
}
return merchandise
}
let tab2Section = CPListSection(objects: tab2Items)
let tab2Template = CPListTemplate(title: "CPListItem", sections: [tab2Section])
// CPTabBarTemplate avec les deux tabs
let tabBar = CPTabBarTemplate(templates: [tab1Template, tab2Template])
interfaceController?.setRootTemplate(tabBar, animated: true)
}
}
Here’s a fast video:


