Xlpagertabstrip: how i can get the current index of selected tab ?

Created on 13 Feb 2017  路  2Comments  路  Source: xmartlabs/XLPagerTabStrip

I have 3 tab and i want to make specific job for each tab : example a want reload the date inside my selected tab by clicking in button in my navigation bar, the problem is the index of selected tab is always wrong . any help ?

awaiting response

Most helpful comment

Hey @samirthebti !

You can use the currentIndex property to get the index of the selected tab and then query the viewControllers property to get the selected viewcontroller.

Let me know if there's anything else i can help you with
Cheers

All 2 comments

Currently public var changeCurrentIndexProgressive: ((oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void)? seems to have problem that always get the previous selected index.

I implement following delegate to get the correct selected index:

public protocol PagerTabStripDelegate: class {

    func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int)
}

public protocol PagerTabStripIsProgressiveDelegate : PagerTabStripDelegate {

    func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool)
}

just get the toIndex value from that

Hey @samirthebti !

You can use the currentIndex property to get the index of the selected tab and then query the viewControllers property to get the selected viewcontroller.

Let me know if there's anything else i can help you with
Cheers

Was this page helpful?
0 / 5 - 0 ratings