EndouMari/TabPageViewController

How to get the index of the view controller tapped?

hjouhi opened this issue · 2 comments

Implementing the TabPageViewController inside a Navigation Controller, how do I get the index that has been selected (so that I can configure the view controller that gets presented for that index)? Is there a delegate function for that?

If tc is your tab controller, then:

  var currentTabIndex: Int? {
    guard let viewController = tc?.viewControllers?.first else { return nil }
    return tc?.tabItems.map{ $0.viewController }.indexOf(viewController)
  }

When I need to call a currentTabIndex variable to get the current tab index?