I have UITextFields on a table to enter values.
Some of these fields accept only numbers. I am using UIKeyboardTypeNumbersAndPunctuation for the keyboardType, and shouldChangeCharactersInRange to filter the characters.
Also, all the corrections are disabled:
textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
On the numeric only fields, when the space key is touched, the keyboard changes to Alphabet.
I know that this is the default behavior.
I want to ignore the space key, and don’t want the keyboard type change.
Is there some way to change this default behavior?
PS: the other numeric keyboard types are not an option. I need the Punctuation!
Thanks
I do not think it is possible to modify the keyboard behavior.
However, you could implement the textField:shouldChangeCharactersInRange:replacementString: from the UITextFieldDelegate protocol to intercept the space (and apostrophe) like this and it seems to work: