IB - how to discard keyboard?

Discussion in 'iOS Programming' started by drivefast, Jan 12, 2009.

  1. drivefast macrumors regular

    Mar 13, 2008
    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.
  2. XForward macrumors newbie

    Jan 12, 2009
    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.

Share This Page