As I point out in my answer here , the UITextField conforms to the UITextInput protocol. Therefore, you call its methods:
[textField replaceRange:textField.selectedTextRange withText:text]
Interesting: "" will do the backspace and, of course, " " will do the space.
This should call the shouldChangeCharactersInRange method automatically. If not, you must do it yourself.
You definitely need to do this if you are going to create a custom keyboard on iOS.
Dan rosenstark
source share