I my app I have four steppers and each has a related field. I have the stepValue of each stepper set to 0.1. The associated fields are editable, and I have them set to have a trailing 0 when editing ends.
Everything works fine. The stepper increments at 0.1 and populates the field. When the field edited ends it has a trailing 0. The problem is that the stepper does not have a trailing zero on the whole number.
So, with the stepper, I get 0.8, 0.9, and then 1 with no training 0, hen 1.1.
How can I make sure I have a trailing 0 with the whole numbers?
@IBAction func editing_Ended_Flds(_ sender: UITextField)
{
let stringValue: String = sender.text ?? ""
if let value = Double(stringValue)
{
sender.text = "\(String(format: "%.1f", value))"
}
}
@IBAction func editingChanged_Flds(_ sender: UITextField)
{
switch sender
{
case fade_In_Fld_Outlet:
fade_In_stepper_Outlet.value = Double(sender.text!) ?? 0.0
case fade_Out_Fld_Outlet:
fade_Out_stepper_Outlet.value = Double(sender.text!) ?? 0.0
case pause_Before_Fld_Outlet:
pause_Before_stepper_Outlet.value = Double(sender.text!) ?? 0.0
case pause_After_Fld_Outlet:
pause_After_stepper_Outlet.value = Double(sender.text!) ?? 0.0
default: break
}
}
@IBAction func stepper_Tapped(_ sender: UIStepper)
{
switch sender
{
case fade_In_stepper_Outlet:
fade_In_Fld_Outlet.text = Double(sender.value).formatted()
case fade_Out_stepper_Outlet:
fade_Out_Fld_Outlet.text = Double(sender.value).formatted()
case pause_Before_stepper_Outlet:
pause_Before_Fld_Outlet.text = Double(sender.value).formatted()
case pause_After_stepper_Outlet:
pause_After_Fld_Outlet.text = Double(sender.value).formatted()
default: break
}
}