Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numeric keyboard with decimal

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 
like image 634
Kevin Avatar asked Feb 16 '16 16:02

Kevin


People also ask

How do you use decimals on a keyboard?

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.

How do I get decimals on my iPhone?

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 #.


2 Answers

Simply change the keyboard type:

self.someTextField.keyboardType = UIKeyboardType.decimalPad 

See the documentation for all the keyboard types.

like image 99
tktsubota Avatar answered Sep 18 '22 22:09

tktsubota


Select Decimal Pad in Keyboard Type for Text Field in Attribute Inspector.

Refer the image below for more detail

enter image description here

like image 30
Naveen Kumar M Avatar answered Sep 21 '22 22:09

Naveen Kumar M