How can I show the numeric keyboard by default on iPhone? How can I show the numeric keyboard by default on iPhone? objective-c objective-c

How can I show the numeric keyboard by default on iPhone?


The UITextInputTraits protocol (which UITextField conforms to) has a keyboardType property of type UIKeyboardType.

myTextField.keyboardType = UIKeyboardTypeNumberPad;


This could be done in the Interface Builder as well:

Number pad2Number pad2


UITextField conforms to UITextInputTraits protocol which means it has keyboardType property which you can set.

myField.keyboardType = UIKeyboardTypeNumberPad;

You can also set it via interface builder. From the text input traits set the keyboard to number pad and that's all.