views:

30

answers:

2

hi i'm Xcode Newb ,In a textfield, when we click on it,

A keyboard appears,but when user press return key

How can i hide it?

A: 

set delegate of UITextField, and over ride, textFieldShouldReturn method, in that method just write following two lines:

[textField resignFirstResponder]; return YES;

that's it. Before writing a code dont forget to set delegate of a UITextField and set Return key type to "Done" from properties window.(command + shift + I).

Matrix
when i do like that for my first field keyboard goes down but for others my app crashes.
aden
+2  A: 

First make your file delegate for UITextField and then add this method to your code ..

-(BOOL) textFieldShouldReturn:(UITextField *)textField{

    [textField resignFirstResponder];
    return YES;
}
Saurabh