开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜