You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use Segmentio together with a UICollectionView. I use the UIScrollViewDelegate to calculate if I want to "snap" to a given cell. I then pass the value to Segmentios selectedItemIndex to let it handle all my UI updating like setting the navigation bar title.
If the "new value" is the same as the selected value though, valueDidChange does not get fired because obviously the value did not change. I instead call segmentio.valueDidChange?(segmentio, segmentio.selectedSegmentioIndex) which seems a little bit unnecessary to me.
How about a SegmentioSelectionCallback for "valueSelected" as well?
How should it look like?
open var valueSelected: SegmentioSelectionCallback?
open var selectedSegmentioIndex = -1 {
didSet {
if selectedSegmentioIndex != oldValue {
reloadSegmentio()
valueDidChange?(self, selectedSegmentioIndex)
}
valueSelected?(self, selectedSegmentioIndex)
}
}
...
segmentio.valueSelected = { segmentio, index in ... }
The text was updated successfully, but these errors were encountered:
I use Segmentio together with a UICollectionView. I use the UIScrollViewDelegate to calculate if I want to "snap" to a given cell. I then pass the value to Segmentios selectedItemIndex to let it handle all my UI updating like setting the navigation bar title.
If the "new value" is the same as the selected value though, valueDidChange does not get fired because obviously the value did not change. I instead call segmentio.valueDidChange?(segmentio, segmentio.selectedSegmentioIndex) which seems a little bit unnecessary to me.
How about a SegmentioSelectionCallback for "valueSelected" as well?
How should it look like?
The text was updated successfully, but these errors were encountered: