I´m building an app with equations and I have used a numeric keyboard but I want to have a decimal slot on it. The default is only numbers. How do you add a decimal input on that keyboard?
This is the code I use to get the numeric keyboard
.keyboardType = UIKeyboardType.NumberPad
The decimal key can appear in two places on the US keyboard, in the bottom row of main keys to the right of 'M', or in an optional numeric keypad. The behavior should be the same regardless of which key is used to enter a decimal.
Here's a longer answer: on an iPhone, you enter decimals by pressing the +*# button in the lower-left corner of the keypad and pressing either * or #.
Simply change the keyboard type:
self.someTextField.keyboardType = UIKeyboardType.decimalPad
See the documentation for all the keyboard types.
Select Decimal Pad in Keyboard Type for Text Field in Attribute Inspector.
Refer the image below for more detail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With