views:

2062

answers:

2

I've got one text entry box in my iphone app, when you touch it in the simulator, the keyboard pops up. But there's no way to get rid of it. Other web pages give solutions, without explaining why they should work, and they don't work for me. One says make the text box's delegate your uiview then call resignfirstresponder on the object, but it never gets called. Any suggestions? Can anybody explain what's actually going on? I can figure it out myself if I knew what the design paradigm was...

Maybe I should just put a "go" button so I have something to get the focus away from the textfield?

+1  A: 

- (BOOL)textFieldShouldReturn:(UITextField *)textField in your delegate is called when the return button is pressed.

You want to call [textField resignFirstResponder] and then return YES. That should do the trick. Also make sure the delegate is set. If in doubt, add a break point or NSLog and verify.

freespace
+1  A: 

One way to do it is to set an object as the delegate to the text field and implement

- (BOOL)textFieldShouldReturn:(UITextField *)textField

in which you call [textField resignFirstResponder]

This will cause the keyboard to disappear when they push the return/go/done button (whatever you set the bottom right keyboard key to be).

See the UITextFieldDelegate reference for more info.

Martin Gordon