user648244
user648244

Reputation: 1278

uitextfield hide keyboard?

On the iphone. When I press on the uitextfield I don't want a keyboard to popup.

I want the same behavior, just no keyboard at all. How can I hide/close the keyboard when the user presses the uitextfield?

Upvotes: 4

Views: 6996

Answers (4)

karthikeyan
karthikeyan

Reputation: 3888

use this method to dismiss a keyboard touch anywhere in the view

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}

or by clicking on keyboard done button

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

Upvotes: 0

Asike
Asike

Reputation: 309

I think you can use

textfield resignFirstResponder

in delegate method -

(void)textFieldDidBeginEditing:(UITextField *)

textField like this:

-(void)textFieldDidBeginEditing:(UITextField *)textField
{
    if (textField == yourTextField){
      [yourTextfield resignFirstResponder];
    }
}

Upvotes: 0

mvds
mvds

Reputation: 47034

If you want the exact same behavior, without the keyboard, try

textfield.inputView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];

Upvotes: 7

unexpectedvalue
unexpectedvalue

Reputation: 6139

Returning NO to UITextFieldDelegate's - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField should do it.

Upvotes: 6

Related Questions