I'm creating an application on the iPad. I create a custom keyboard using UITextField
's inputView
property. To insert text at the cursor position, I use the copy & paste method (http://dev.ragfield.com/2009/09/insert-text-at-current-cursor-location.html), which works fine. Now, I want to create the delete key. The code that I'm using is:
if (textField.text.length > 0) {
textField.text = [textField.text substringToIndex:textField.text.length-1];
}
However, as you may know, it only deletes the last character no matter where the cursor is. Does anyone know a better solution?
Thank you very much!
Just call [textField deleteBackward]
. It takes care of cursor position and highlight for you.
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