I have implemented a custom keyboard view in an iOS application. I have several UITextFields that use this keyboard. Some of these UITextFields have delegates that override shouldChangeCharactersInRange
. However if my keyboard just sets the text value in the text field, the shouldChangeCharactersInRange message is not sent. What I think I need is to actually do something like SendKey and send the key code to the UITextField.
Any suggestions?
An object that displays an editable text area in your interface.
Via Tap Gesture This is the quickest way to implement keyboard dismissal. Just set a Tap gesture on the main View and hook that gesture with a function which calls view. endEditing .
As I note in my answer here, the UITextField
conforms to the UITextInput
protocol. So you call its methods:
[textField replaceRange:textField.selectedTextRange withText:text];
Of interest: ""
will perform a backspace and, of course, " "
will do a space.
This should call the shouldChangeCharactersInRange
method automatically. If not, you'd have to do that yourself.
You definitely need to do this if you are going to create a custom keyboard on iOS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With