Remove focus from text field/resign keyboard
I have a UI with three text fields and one button. All three text fields use the Number Pad keyboard, which don't have a Return key to hide the keyboard.
What I'm looking for is that when I tap the button, the text field that has the focus (one always does), loses focus. I don't know which text field will have the focus when the button is tapped.
All the text field implement delegates.
My first thought was to send a simulated return key with the button tap, but I couldn't figure out how to do this. I tried the textfielf.end-editing() with a couple of different delegate methods, but it didn't work.
Can anybody suggest a way to remove the focus from a text field?
delegate.textfield_did_begin_editing()you should be able to keep track of which of the three fields has the focus. When the button in tapped, you could call
textfield.begin_editing()on one of the two other textfields.
That's a very slick solution. I actually made a dummy text field, hid it behind another field, and set the focus to that on button press.
Thanks so much. I push this app on people like a drug dealer. I love it.
You can hide your dummy text field by setting its height and/or width to zero.