Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current index inside child class. #446

Open
vanjaruzic opened this issue Sep 7, 2017 · 3 comments
Open

Current index inside child class. #446

vanjaruzic opened this issue Sep 7, 2017 · 3 comments

Comments

@vanjaruzic
Copy link

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.

@junweimah
Copy link

Have you found answer to this?

@vanjaruzic
Copy link
Author

vanjaruzic commented Feb 7, 2018

@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)

        }
    }

@Arshad-iOSDeveloper
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants