Pergunta

I have three text input fields that I clear after the user has added data to a database:

 self.textMonth.text  = @"";
 self.textTemp.text   = @"";
 self.textCloud.text  = @"";

How to I put the cursor in any one of those fields subsequently?

I have tried a number of the solutions provided elsewhere but none seem to work. Many thanks. EH

Foi útil?

Solução

just make your text field first responder using becomeFirstResponder like....

 [self.textMonth becomeFirstResponder];

to change textfield subsequently use textFieldShouldReturn

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if([self.textMonth isFirstReponder])
    {
        [self.textTemp becomeFirstResponder];
    }
    else if([self.textTemp isFirstReponder])
    {
        [self. textCloud becomeFirstResponder];
    }
    else if([self.textCloud isFirstReponder])
    {
        [self.textMonth becomeFirstResponder];
    }
    return YES;
}

Hope it will help to solve your problem

Outras dicas

try this:

[self.textMonth becomeFirstResponder];

Based on conditions you can use becomeFirstResponder

[self.textMonth becomeFirstResponder];
[self.textTemp becomeFirstResponder];
[self.textCloud becomeFirstResponder];
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top