Skip to content
This repository was archived by the owner on Nov 6, 2026. It is now read-only.
This repository was archived by the owner on Nov 6, 2026. It is now read-only.

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

Open

Description

@hjouhi

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?

Activity

  1. LucasGG commented on Sep 1, 2016

    @LucasGG

    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)
      }
    
  2. dp4dileep commented on Oct 21, 2016

    @dp4dileep

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions