In my app users need to be able to enter numeric values with decimal places. The iPhone doesn't provides a keyboard that's specific for this purpose - only a number pad and a keyboard with numbers and symbols.
Is there an easy way to use the latter and prevent any non-numeric input from being entered without having to regex the final result?
Thanks!
Numbers that contain a decimal point are stored in a data type called REAL. Variables that use the real data type can accept both positive and negative numbers with a decimal place.
Use scientific notation, not e (which Mastering evaluates as the constant 2.718...) or E. For example, enter 1.23*10^5 instead of 1.23e+5 or 1.23E+5. Use commas only as separators between multiple expressions within a single answer box, such as "1999,2009".
I think it would be good to point out that as of iOS 4.1 you can use the new UIKeyboardTypeDecimalPad
.
So now you just have to:
myTextField.keyboardType=UIKeyboardTypeDecimalPad;
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