Hide keyboard when uitextfield is pressed

Discussion in 'iPhone/iPad Programming' started by XcodeNewb, Feb 16, 2009.

  1. macrumors member

    I am able to hide the keyboard when the user clicks off of a uitextfield by using the [sender resignFirstResponder] command, but I want to hide it as soon as the user clicks inside the textfield. Is this possible?

    I have the uitextfield "Editing Did begin" etc etc set up to call a method and that is using the same commands ( [sender resignFirstResponder] ) but the keyboard never disappears? I can see the method is being called and the commands are being run but the keyboard just stays there.

    I want to call another method to change views when the user selects the uitextfield. The view changes but the keyboard is up and will not go away.

    Any suggestions?

  2. Moderator


    Staff Member

    Don't use a UITextfield for input that isn't going to let the user type in some text? Use a different mechanism, perhaps a button instead?
  3. macrumors member

    I am using the textfield to have the interface be consistent. There are other textfields they can edit but I wanted the look and feel to be the same. I thought about using a label but it may look a little odd.

    It just seems weird that I cannot force the keyboard to not show up when a user selects the textfield. There should be a "no keyboard" option for textfields.
  4. Moderator


    Staff Member

    Would kinda defeat the purpose of textfields then, wouldn't it?

    Have you tried disabling the textfield? You then might also need to place a transparent view over the textfield to trap the tap so that you can call your custom event.

Share This Page