+ Reply to Thread
Results 1 to 1 of 1

Removing The Keyboard when Done is Tapped in iPhone SDK

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 ...

          
   
  1. #1
    The Man Behind It All Fahad's Avatar
    Join Date
    Jun 2009
    Posts
    789

    Default Removing The Keyboard when Done is Tapped in iPhone SDK

    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.

    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
    2) Add in your viewcontroller.m file the following code:

    Code:
    - (IBAction) editingEnded2:(id)sender{ 
    
    [sender resignFirstResponder];
    
    }
    3) Open Interface builder and connect your textfield with the IBAction above, NOTE: when connecting the action choose "Did End on Exit"


    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

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts