Search code examples
iphoneiosuitextfield

Can I detect the delete key even if the UITextField is empty?


When UITextField contains nothing, pressing the delete key of keyboard won't call any of UITextFieldDelegate's methods.

How can I detect it?


Solution

  • Its possible to put a button over it, but that's a bit fragile since keyboard layout could change with different iOS versions and there certainly are different keyboard layouts for different languages.

    Look at the "Managing Text Fields and Text Views" Apple doc. Im sure there is a way to do this. Its something like a UITextField implements a protocol to get keyevents. One of those key events will probably be a delete key, so you could override whatever method receives these and get it that way.