0

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.

Pradeep
  • 37
  • 4

3 Answers3

0

I like keeping a button on the top-left of my "editable" views that resembles the iPad icon of "hide keyboard". This way, the user can always hides the keyboard when needed.

Also, if your UITextField is not editable, the keyboard will not show.

Sergio Moura
  • 4,888
  • 1
  • 21
  • 38
  • Thanks for spare this answer. but i did all those things stil the return key is not enabled until i type some characters in textfield. – Pradeep Dec 24 '10 at 10:01
0

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

Vipul Parmar
  • 104
  • 1
  • 4
  • Thanks for spare this answer. but i did all those things stil the return key is not enabled until i type some characters in textfield. – Pradeep Dec 24 '10 at 10:01
  • Hi Pradeep, I am not very clear about your problem. Can you mention your problem briefly (I mean to say explain briefly what you have did in your project) or share some brief of your code. So, I will be pretty clear about your problem and then I will be very happy to answer your question. :) – Vipul Parmar Dec 28 '10 at 06:13
0

By default the return key in UITextField is not enabled until the user has typed some text. You can change this behavior so that the return key is always enabled by setting enablesReturnKeyAutomatically, either programatically with the UITextInputTraits protocol or in Xcode IB.

paul.lander
  • 458
  • 4
  • 5