I'm trying to learn more about CarPlay. Specifically using CPTabBarTemplate
(a new template as of 2020 and iOS 14).
What I'm looking to do is programmatically change the selectedTemplate
, just as if I were updating a selectedTab
in a UITabBar
.
An example flow would be a CPTabBarTemplate
with two tabs. A CPPointOfInterestTemplate
and a CPInformationTemplate
.
tabBarTemplate = CPTabBarTemplate(templates: [pointOfInterestTemplate, informationTemplate])
The user could select a point of interest and from the poi detail screen choose a button that might say "Select", just like in Apple's example from their WWDC20 talk.
Upon pressing "Select", I want to programmatically take the user to the informationTemplate
of the tabBarTemplate
and then use the selected location's details to populate information in the informationTemplate.
I might not be understanding the way Apple expects CPTabBarTemplate
to be used. There does exist a selectedTab
property of CPTabBarTemplate
. However, that property is get
only. Which leads me to believe that the desired way to switch tabs is let the user tap the next tab themselves.
I'd be grateful for any insight. If anyone knows how to programmatically update the selected tab of a CPTabBarTemplate
that would be dandy.
Thanks for reading!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…