Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arubinst

macrumors 6502
Original poster
May 26, 2008
329
191
Lausanne - Switzerland
Hi,

I've googled around for this problem but I find nothing. I'm wondering if I'm the only one...

I have setup a view with 2 TextFields in IB. Delegates of the TextFields are correctly set and the ViewController implements the UITextFieldDelegate protocol.

I would like to dismiss the keyboard with the "Done" key, but the key is grayed out while the TextField is empty. Once I type any character, the Done key is enabled and I can dismiss the keyboard with:

Code:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
	NSLog(@"textFieldShouldReturn");
	[textField resignFirstResponder];
	return YES;
}

So, what am I missing? Why is the "Done" key disabled when the TextField is empty?

By the way, I looked at the UICatalog sample program and couldn't figure out how they handle the keyboard hiding.

Another question: How do I dismiss a "Phone Pad" or "Number Pad" keyboard? The textFieldShouldReturn is ignored since there is no Return or Done key. I can set a "Save" or "Cancel" button somewhere in the navigation bar but I really don't know what those buttons need to do in order to hide this keyboard.

Thanks in advance,

Arubinst
 
Hi,

I'm very new to XCode but have you tried to uncheck the "Auto-enable Return Key" text field attribute in Interface Builder ?
 
I'm still wondering the answer to the second question. How do you hide the number pad keyboard? Is there a way to add a "Done" button to the bottom left key on the pad, since it is an empty spot?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.