View Full Version : IB - how to discard keyboard?
Jan 13, 2009, 12:40 AM
is there any IB combination of settings that i can have for an UITextField (or something similar for that matter), that would make the keyboard disappear when the return, done or whatever button is pressed? i know how to do it with resignFirstResponder, but i have a feeling that there's got to be something easier than that. thanks.
Jan 13, 2009, 01:42 AM
To make the keyboard retract, I usually do 2 things:
1. Make a big button that takes up the entire view. Set the button type to custom, and send it to the back of the layout. Then connect the "Touch Up Inside" event to an action method that calls resignFirstResponder on the sender.
2. Connect the "Did finish on Exit" event (I think that's what it's called, I'm not looking at it right now, but it's the top-most event in the Connections inspector), to an action method that calls resignFirstResponder on the sender (can be the same method as above). This will cause the keyboard to retract when the "Done" key is pressed (provided that you have set the return key type to Done).
Hope that helps.