Have you tried:
[viewReceivingKeys resignFirstResponder];
where viewReceivingKeys
is the UIView that is receiving the text input?
Have you tried:
[viewReceivingKeys resignFirstResponder];
where viewReceivingKeys
is the UIView that is receiving the text input?
use a navigation controller and pop the view when done?
for example, I use code like this to slide an about box in:
[[self navigationController] presentModalViewController:modalViewController animated:YES];
and then when the button in that about box is clicked, I use this to get rid of it:
[self.navigationController dismissModalViewControllerAnimated:YES];
In my case the about box occupies the whole screen, but I don't think it would have to for this to work.
edit: I think I may have misunderstood your question. Something along the lines of my code would be if you are faking the whole keyboard view yourself. I think that resign first responder is the right way to do it if it is the normal keyboard with your toolbar added on top.
If your building your own views in Interface Builder, set your view controller to be delegate for the text field and implement textFieldShouldReturn: from UITextFieldDelegate in your views controller.
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField
{
NSLog(@"%@ textFieldShouldReturn", [self class]);
[theTextField resignFirstResponder];
// do stuff with the text
NSLog(@"text = %@", [theTextField text]);
return YES;
}
UITextFieldDelegate textFieldShouldReturn: in the iphone cocoa docs
I have the same question as Dec, but I want the "go" button to be the "Done" button. Right now, it says "Done" but when I press it it goes down a line. Im new to this, so if your answer is just "Type in the code..." I won't know where to put it. Thanks!
I read that its not OK to call resignFirstResponder directly: only after a lot of wasted effort did I realize I was looking at the MAC documentation, not the iPhone docs. Its OK on iPhone, not OK on MAC. Grrr.