How can I show the numeric keyboard by default on iPhone?
This could be done in the Interface Builder as well:
The UITextInputTraits
protocol (which UITextField
conforms to) has a keyboardType
property of type UIKeyboardType
.
myTextField.keyboardType = UIKeyboardTypeNumberPad;
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.