"Return" on the keyboard after selecting a text field does nothing?

Discussion in 'iOS Programming' started by MythicFrost, Dec 21, 2009.

  1. MythicFrost macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #1
    I assume I have to tell it what the Return button does in the keyboard after you've selected my text field and typed your message, how do I do that?

    Thanks
     
  2. KoolStar macrumors demi-god

    KoolStar

    Joined:
    Oct 16, 2006
    Location:
    Kentucky
    #2
    You need to implement the UITextDelegate and the resign the first responder on the return button press.
     
  3. MythicFrost thread starter macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
  4. mandude macrumors member

    Joined:
    Nov 19, 2009
    #4
    hey all you gotta do is this : )


    h.file:

    Code:
    
    @interface..... {
    
       UITextField *textField;
    }
    @property (nonatomic, retain) IBOutlet UITextField *textField;
    -(IBAction)textFieldDoneEditing:(id)sender;
    //* this is for if you would like the keyboard to disappear from touching the background :
    -(IBAction)backgroundTap:(id)sender;
    

    in interface builder connect that to the text field of your choice, and use DID END ON EXIT if you chjoose to use the backGroundTap method, in the main window, click on the gray box named VIEW click on the inspector, and click the 4th tab, or press COMMAND 4 then at the topo change the class from UIView to UIControl then go to the connections and drag the TOUCH DOWN to the Files Owner and select BackgroundTap


    m. file:

    Code:
    
    -(IBAction)textFieldDoneEditing:(id)sender {
    [sender resignFirstResponder];
    }
    
    -(IBAction)backgroundTap:(id)sender {
    [textField resignFirstResponder];
    }
    
    
    
     
  5. MythicFrost thread starter macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #5
    Awesome man thanks a lot, I've got it working without using IB though. Thanks again!
     

Share This Page