开发者

iOS: how to send the keyboard down after typing in textField

开发者 https://www.devze.com 2022-12-14 22:40 出处:网络
I want to send the keyboard down after writing in textField. How can I do this? 开发者_开发技巧Any help would be appreciated. Implement the - (BOOL)textFieldShouldReturn:(UITextField *)textField; de

I want to send the keyboard down after writing in textField.

How can I do this?

开发者_开发技巧Any help would be appreciated.


Implement the - (BOOL)textFieldShouldReturn:(UITextField *)textField; delegate method and tell the text field to resign it's first responder status.

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


STEP-1:

You need to set the delegate of the textField to File's Owner (using interface builder)

or

textField.delegate = self; from the viewController programmatically first

STEP-2:

And you implement the method:

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

Hope this helps.


- (IBAction)textFieldDoneEditing:(id)sender{ 
    [sender resignFirstResponder]; 
}

connect this to didEndOnExit action of your textfield

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号