Search code examples
iphoneiosobjective-ckeyboarduitextfield

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


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?


Solution

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

    myTextField.keyboardType = UIKeyboardTypeNumberPad;