Is there a way to fix the decimal point on the DecimalPad keyboard?

Asked 1 years ago, Updated 1 years ago, 106 views

There are some localization applications that specify the DecimalPad on the keyboard.
iOS Settings If I select Italy as the format setting of the app, the DecimalPad period will be comma, but this is a little sick (to add values to DB and aggregate them), so I would like to ignore the settings and display a keyboard that always shows periods. Is this possible?
If possible, I'm looking for a simple way to avoid implementing a custom keyboard.

swift ios localization

2022-09-30 21:17

1 Answers

It's not a direct answer, but if it's for localization, shouldn't DecimalPad also show localization?

If you mean DB values and aggregates, NSNumberFormatter will interpret the numeric data in a format that matches your current user settings, so if you have a comma on the DecimalPad, you will interpret the comma as a decimal point.

let numberFormatter=NSNumberFormatter()
iflet value = numberFormatter.numberFromString(textField.text???") ?.doubleValue{
    print(value)
}

You will also use NSNumberFormatter() to display numeric values on the screen.

numberFormatter.maximumFractionDigits=10
textField.text=numberFormatter.stringFromNumber (123.456)
//->123,456 is displayed in Italian state

"If all the Japanese staff are ""localized"", they tend to be distracted by the translation of the wording that appears, but I think it would be better to localize ""decimal points"" and ""date format"" (Japanese style yyyy/MM/dd format is rarely used in Europe and the U.S.)

"


2022-09-30 21:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.