I have a UITextField
and its keyboard type is DecimalPad
.
The app only supports one language (italian) and the decimal pad displays a comma instead of a period as a decimal separator.
I need to change that comma to a period, so that, whatever locale is the user device set to, I always have a period as a decimal separator.
I tried subclassing my textfield and override the variable textInputMode: UITextInputMode
(then I assigned my custom class to the textfield), but it didn't work. I supposed the following would immediately change my comma:
override var textInputMode: UITextInputMode? {
for t in UITextInputMode.activeInputModes {
if t.primaryLanguage == "en-EN" {
return t
}
}
return super.textInputMode
}
Is there any way to do what I'm trying to do or is it not possible?
I have found some similar questions but no definitive answer.
This is NOT a duplicate question: you are confusing the DecimalPad and the default iOS textual keyboards. Things are different. Moreover, the solution in that post is not acceptable because it lets you SWITCH between keyboards and this is not my case because it would cause lots of issues.
As far as I know, there's NO way to do want I want to do using the DecimalPad, the only solution I found could involve the creation of an entirely custom keyboard.