make the textfield to be the first responder again
-
02-06-2021 - |
Pergunta
- (IBAction)textFieldDoneEditing:(id)sender {
[sender resignFirstResponder];
[sender becomeFirstResponder];
}
I have a UItextField object, and link the "Did End On Exit" to the "textFieldDoneEditing" action. After I press the Done button on the keyboard, why is it dismissed?
Solução
In your method call another method like bellow code
in yourViewController.h
file just define bellow method
-(void)MykeyBoardUp;
and in .m file
-(void)MykeyBoardUp{
[yourtextFieldobject becomeFirstResponder];
}
after then in your .m file in bellow method just call this method like this
- (IBAction)textFieldDoneEditing:(id)sender {
[sender resignFirstResponder];
[self performSelector:@selector(MykeyBoardUp) withObject:nil afterDelay:0.2];
}
May this help you......
Outras dicas
in the above code, when you run [sender resignFirstResponder]
keypad will hide
so calling next method is of no use
but if you still want to get keypad again, call it using UITextField
object
i.e.
if in .h
IBOulet UITextField *txt;
then call
[txt becomeFirstResponder]
but still i don't understand, what is your purpose.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow