【问题标题】:How to get index of selected tab in UITABBAR如何在 UITABBAR 中获取选定选项卡的索引
【发布时间】:2018-06-13 00:43:10
【问题描述】:

如何快速获取UITabBar项的选定索引 我不是在谈论 UITabBarController

我知道我可以使用 UITabBarItem.tag。

但对我来说,我不能将标签用于选定的索引,因为它已经用于其他目的。 有没有其他方法可以让我快速获取所选标签的索引。

【问题讨论】:

    标签: ios objective-c swift swift3 uitabbarcontroller


    【解决方案1】:

    https://developer.apple.com/documentation/uikit/uitabbar

    UITabBar 有 2 个属性“items”和“selectedItem”,都是 UITabBarItem 类型。

    所以你可以通过获取“items”中“selectedItem”的索引来获取选定项目的索引。

    items.index(of: selectedItem)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-22
      • 2015-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-22
      • 1970-01-01
      • 2017-12-31
      相关资源
      最近更新 更多