0

我正在尝试了解有关 CarPlay 的更多信息。具体使用CPTabBarTemplate(截至 2020 年和 iOS 14 的新模板)。
我要做的是以编程方式更改selectedTemplate,就像我在更新 aselectedTab中的UITabBar.
一个示例流程是CPTabBarTemplate带有两个选项卡的。一个CPPointOfInterestTemplate和一个CPInformationTemplate

tabBarTemplate = CPTabBarTemplate(templates: [pointOfInterestTemplate, informationTemplate])

用户可以选择一个兴趣点,然后从 poi 详细信息屏幕中选择一个可能显示“选择”的按钮,就像 Apple 在他们的WWDC20 演讲中的示例一样。 在此处输入图像描述

按下“选择”后,我想以编程方式将用户带到其中informationTemplatetabBarTemplate然后使用所选位置的详细信息在informationTemplate.

我可能不理解 Apple 期望CPTabBarTemplate的使用方式。确实存在 的selectedTab属性CPTabBarTemplate。但是,该属性是get唯一的。这让我相信切换标签的理想方式是让用户自己点击下一个标签。

我会很感激任何见解。如果有人知道如何以编程方式更新 a 的选定选项卡,CPTabBarTemplate那将是花花公子。

谢谢阅读!

4

1 回答 1

0

我认为目前这是不可能的。的公共接口CPTabBarTemplate很短,但我什至无法通过调用私有 api 来使其工作。调用tabTemplate.perform(Selector(("setIndexOfSelectedTab:")), with: 1)和调用函数都没有tabTemplate.perform(Selector(("handleActionForControlIdentifier:")), with: tabTemplates[1].value(forKey: "identifier"))成功(即使标签栏委托函数是使用正确选择的模板调用的)。

于 2021-01-06T12:22:20.150 回答