PDA

View Full Version : Hide keyboard when uitextfield is pressed




XcodeNewb
Feb 16, 2009, 11:48 AM
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?

Thanks



dejo
Feb 16, 2009, 11:59 AM
Any suggestions?
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?

XcodeNewb
Feb 16, 2009, 12:02 PM
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.

dejo
Feb 16, 2009, 06:18 PM
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.
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.