IB - how to discard keyboard?

Discussion in 'iPhone/iPad Programming' started by drivefast, Jan 12, 2009.

  1. macrumors regular

    Joined:
    Mar 13, 2008
    #1
    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. macrumors newbie

    Joined:
    Jan 12, 2009
    #2
    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