【问题标题】:selectedViewcontroller not working for tabbarcontroller in tvOS 10selectedViewcontroller 不适用于 tvOS 10 中的 tabbarcontroller
【发布时间】:2016-07-15 09:43:12
【问题描述】:

我有一个rootviewcontroller,它正在扩展UITabBarController。它有几个孩子viewcontrollers

我想要的只是以编程方式从第一个中选择第二个/第三个/..viewcontroller。我用过

`.selectedViewController`, `.selectedIndex`, `.navigationController.tabBarController.tabBar.selectedItem = ...` 

以及这个主题的所有变体。我在使用时注意到以下内容

`tabBarController.selectedViewController = tabBarController.viewControllers?[1]` 

tabBarController 会显示第二个viewcontroller,但会返回到第一个viewcontroller。我有预感这是焦点引擎,但我现在迷路了。

【问题讨论】:

  • 你在哪里做所有这些代码?

标签: ios swift uitabbarcontroller tvos focus-engine


【解决方案1】:

不完全确定它是否相关,但我有一个 tvOS 应用程序,其中我在 UITabBarController 中有几个 UIViewControllers,我无法在标签栏中选择它们,并且一旦我升级到 tvOS 10,标签栏就会消失。

原来的问题是这些屏幕上没有任何可聚焦的元素(按钮等),所以我不得不为一些视图创建子类对象并使canBecomeFocused 属性返回“true”。

见:How to make a UIView focusable using the focus engine on Apple TV

您必须实现第二件事以使它们显得专注,但如果您实际上不希望这样做,则可以跳过它。

【讨论】:

    【解决方案2】:

    我正在为每个控制器设置一个 UITabBarItem。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-07
      • 1970-01-01
      • 2020-10-03
      • 2019-02-03
      相关资源
      最近更新 更多