James James - 1 year ago 159
Objective-C Question

How To Add Decimal To Number Pad - iOS


How would I create a number pad with a decimal option in interface builder? The number pad that is provided doesn't show a decimal option.


Answer Source

In iOS 4.1, there is a number pad with a decimal point available. You can select it programatically (in case you are supporting versions of iOS before 4.1) like so:

    inputBoxTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
    if (([[[UIDevice currentDevice] systemVersion] doubleValue] >= 4.1)) {
        inputBoxTextField.keyboardType = UIKeyboardTypeDecimalPad;

You could choose any appropriate keyboard type (line 1). In this case, NumbersAndPunctuation includes a period in case the user's iOS version is before 4.1.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download