ios - The number of digits on textField -
i'm working on app , need on uitextfield
.
i want make number of digits appear specific (e.g. 3) knowing numbers shown on uitextfield
value of slider between range of 1 0 (i need range,) numbers between them (0.5 , 0.6 ...).
the numbers getting 6 digits (0.123456) , show less that.
i have tried funcion after added uitextfielddelegate
:
func textfield(textfield: uitextfield, shouldchangecharactersinrange range: nsrange, replacementstring string: string) -> bool { ... }
but it's not working. got 1 use function:
@ibaction func testfield(sender: uitextfield) { let thelength = sender.text!.characters.count if thelength = >= 3 { let therange = range(start: sender.text!.startindex, end: sender.text!.startindex.advancedby(3)) var newdi = sender.text!.substringwithrange(therange) sender.text = newdi } }
also nothing changed.
note: have more uitextfields
fix.
use this.
textfield.text = string(format: "%0.1f", slider.value)
Comments
Post a Comment