uitextfieldiphone-sdk-4.1

Keypad in iphone is not going?


In my application, whenever i tap a textfield the keypad will be visible, i have used the

[textField resignFirstResponder];

to that textfield's IBOutlet, but still the return key in keypad is not enabled, so cannot make the keypad go away.It enables only after i type some Characters in the textfield.


Solution

  • First make sure you had set the "delegate" of your textfield in Interface Builder. You can set it by dragging its "delegate" attribute link to the File's Owner.

    alt text Here titleFld is the name of my UITextField.

    Setting delegate of your textfield will enable your compiler to call your "textfield delegate methods".

    you can also do this programmatic by

    [yourTextFieldName setDelegate: self];
    

    //Set "self" if you have its delegates method in the same file.

    If you want to move out your keyboard from the screen on its "return" key press then below code will do this task.

    - (BOOL)textFieldShouldReturn:(UITextField *)textField
    {
         [textField resignFirstResponder];
         return NO;
    }
    

    But make sure you set the delegate of your textfield...