EndouMari / TabPageViewController

Paging view controller and scroll tab view
MIT License
1.39k stars 221 forks source link

How to get the index of the view controller tapped? #26

Open hjouhi opened 8 years ago

hjouhi commented 8 years ago

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?

LucasGG commented 8 years ago

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)
  }
dp4dileep commented 7 years ago

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