XLPagerTabStrip
XLPagerTabStrip copied to clipboard
Current index inside child class.
How to get current index inside child class, which, in my case, inherits UITableViewController? Other answers for similar questions didn't helped me...
Thanks for help in advance, cheers.
Have you found answer to this?
@junweimah
Use
public var changeCurrentIndexProgressive: ((_ oldCell: ButtonBarViewCell?, _ newCell: ButtonBarViewCell?, _ progressPercentage: CGFloat, _ changeCurrentIndex: Bool, _ animated: Bool) -> Void)?
inside your PagerVC viewDidLoad. Inside closure you can get child's current index every time.
Example:
override func viewDidLoad() {
super.viewDidLoad()
changeCurrentIndexProgressive = { (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
guard changeCurrentIndex == true else { return }
print(self.currentIndex)
}
}
@junweimah
Use
public var changeCurrentIndexProgressive: ((_ oldCell: ButtonBarViewCell?, _ newCell: ButtonBarViewCell?, _ progressPercentage: CGFloat, _ changeCurrentIndex: Bool, _ animated: Bool) -> Void)?
inside your PagerVC viewDidLoad. Inside closure you can get child's current index every time.
Example:
override func viewDidLoad() { super.viewDidLoad() changeCurrentIndexProgressive = { (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in guard changeCurrentIndex == true else { return } print(self.currentIndex) } }
print(self.currentIndex) it is returning some random indexes, not working