This is a discussion on Removing The Keyboard when Done is Tapped in iPhone SDK within the iPhone/iPad Programming Tutorials forums, part of the Programming Section category; When you add a UITextField, users can type in text in it, here I'll show you how to make the ...
When you add a UITextField, users can type in text in it, here I'll show you how to make the keyboard go away (this is not done by default by iPhone OS)
1) 1st you need to make an IBAction, you can name it whatever you want, I'll name it editingEnded2.
2) Add in your viewcontroller.m file the following code:Code:#import <UIKit/UIKit.h> @interface Control_FunViewController : UIViewController { UITextField *username; UITextField *password; } @property (nonatomic, retain) IBOutlet UITextField *username; @property (nonatomic, retain) IBOutlet UITextField *password; -(IBAction) editingEnded2:(id)sender; @end
3) Open Interface builder and connect your textfield with the IBAction above, NOTE: when connecting the action choose "Did End on Exit"Code:- (IBAction) editingEnded2:(id)sender{ [sender resignFirstResponder]; }
And thats about it, hope this guide helps you, if you have any problem or questions please leave a comment.
Last edited by Fahad; 05-15-2010 at 04:06 PM.
MozyMac Founder,Chairman and CEO
MacBook Pro Unibody late 2008 2.4Ghz 4GB ram 250GB HD
MozyMac Youtube Channel