Jump to content
5 posts in this topic

Recommended Posts

Hey, im trying to get involved with the new iPhone SDK with interface builder. I prefer to work with a gui rather than make one with code, so i try to do as much as possible using interface builder. I understand all the Hello World tutorials and everything but i can't figure out something with a text field. I can put the text field into the window, write the classes, build and go, and when the program runs i can click the text field and make the on-screen keypad come up. However, i cant figure out a way to make the keypad dissapear when i click the return / done button. If someone can figure out how to do this using interface builder I would really appreciate some help. I think it has something to do with the editingDidFinish event but im not sure. Thanks in advance.

Which version of the SDK are you using?

I just downloaded Beta 3 and I have a kind of the same problem only I don't even get a "close" button on the keypad.

All the checkboxed a filled in and everything else works. If I click in another textfield which requires say text input instead of the number keypad the keypad changes but I can never get rid of it...

 

A bug perhaps?

No offense to either of you, but you really need to read the docs. Right on the iPhone SDK developer page (http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhone101/Articles/chapter_1000_section_1.html) you will find a tutorial on how to dismiss the keypad.

 

Now, the answer: You need to implement the UITextFieldDelegate (see docs) and them implement the following method:

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
[theTextField resignFirstResponder];
return YES;
}

 

Then somewhere in your controller add:

textField.delegate = self;

  • 5 months later...

biggrin.gif I thought i need only to setup an empty callback (ie IBAction) for "Did End On Exit" event of the UITextField (as IBOutlet) in the InterfaceBuilder!

 

Like this:

 

//header

 

@interface MyView : UIView

{

IBOutlet UITextField *name;

}

 

And the keyboard will be hidden after editing is complete.

 

And the keyboard will be hidden after editing ends.

 

- (IBAction)doneButtonOnKeyboardPressed: (id)sender;

 

//m-file

 

@implementation MyView

 

- (IBAction)doneButtonOnKeyboardPressed: (id)sender

{}

 

@end

×
×
  • Create New...