amratab / FlexibleSteppedProgressBar

Flexible Stepped Progress Bar for IOS
Other
575 stars 113 forks source link

didSelectItemAtIndex() delegate not fired after setting current index #2

Closed aliasdoc closed 7 years ago

aliasdoc commented 7 years ago

Hi, for first, good job !

I just see that didSelectItemAtIndex() delegate method is not fired after setting current index, just need to call in setter


FlexibleSteppedProgressBar.swift

/// The current selected index
    open var currentIndex: Int = 0 {
        willSet(newValue){
            if let delegate = self.delegate {
                delegate.progressBar?(self, willSelectItemAtIndex: newValue)
            }
        }
        didSet {
//            animationRendering = true
            self.setNeedsDisplay()
            if let delegate = self.delegate {
                delegate.progressBar?(self, didSelectItemAtIndex: currentIndex)
            }
        }
    }
amratab commented 7 years ago

thanks! Do you mean its not getting called from your code? Can you please show me the initialization code you have used?

aliasdoc commented 7 years ago

Hi @amratab, I'm doing this way:

self.masterViewController.stepView.currentIndex = 1
self.masterViewController.stepView.completedTillIndex = 1
amratab commented 7 years ago

I am sorry for replying so late. You have to set delegate inside your controller as showed in the README. progressBar.delegate = self In your case, I guess self.masterViewController.stepView.delegate = self.masterViewController