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?
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.
If you want to show a numerical keyboard but also need to be able to use decimal points, currency symbols, or other characters, you can have the keyboard default to the back side of the alphabet keyboard.
currentTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
来源:https://stackoverflow.com/questions/3796772/how-can-i-show-the-numeric-keyboard-by-default-on-iphone


