I have a SliderRow
and I would like to take an action but only if the slider is released.
The .onChange
does the action every time the user slides a bit (of course). The .onCellHighlightChanged
does not work for the SliderRow
.
An option for .onSliderReleased
would be great;)
DoI have another options in meanwhile?
<<< SliderRow("Barrel") { row in
row.title = "Barrel"
row.value = Float(UserDefaultsManager.Barrel())
row.steps = 19
row.displayValueFor = { row in
return "\(Int(row ?? 0)) bbl"
}
}.cellSetup { cell, row in
cell.imageView?.image = UIImage(systemName: "antenna.radiowaves.left.and.right")
cell.slider.minimumValue = 5
cell.slider.maximumValue = 100
}.onChange { row in
let Barrel = Double(row.value ?? 50)
UserDefaultsManager.set(Barrel: Barrel)
ConnectionManager.reconnect()
}
cell.slider.isContinuous = false
is half of the way, tanks for that
but it also disables the value update of the slider
so the user have "to guess" what value will be set
got it working with
cell.slider.addTarget(self, action: #selector(self.sliderDidEndSliding), for: [.touchUpInside, .touchUpOutside])
and
@objc private func sliderDidEndSliding() {
//do some magic
}
There is a property isContinuous
in UISlider
which controls the behavior.
.cellSetup { cell, row in
cell.imageView?.image = UIImage(systemName: "antenna.radiowaves.left.and.right")
cell.slider.minimumValue = 5
cell.slider.maximumValue = 100
cell.slider.isContinuous = false
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.