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

Pablo picture Pablo · Sep 26, 2010 · Viewed 46k times · Source

I'm trying the following with no luck. When the user click on a UiTextfield I need to change the keyboard view to the numeric view automatically, is this possible?

Answer

Jacob Relkin picture Jacob Relkin · Sep 26, 2010

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

myTextField.keyboardType = UIKeyboardTypeNumberPad;