IOS input verification code or password, automatic next digit instance

Time:2020-9-30

The system has no textfeild related proxy method when the input changes… So we add a monitor to achieve the following effect

Auto jump to next bit

 

The main codes are as follows:


[_code1F becomeFirstResponder];
  [_code1F addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  [_code2F addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  [_code3F addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  [_code4F addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  [_code5F addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  [_code6F addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];

-(void)textFieldDidChange :(UITextField *)textField{
  if (textField.text.length == 1) {
    if (textField == _code1F) {
      [_code2F becomeFirstResponder];
    }else if (textField == _code2F){
      [_code3F becomeFirstResponder];
    }else if (textField == _code3F){
      [_code4F becomeFirstResponder];
    }else if (textField == _code4F){
      [_code5F becomeFirstResponder];
    }else if (textField == _code5F){
      [_code6F becomeFirstResponder];
    }else{
      [self.view endEditing:YES];
    }
  }
}

The above example of IOS input verification code or password, automatic next digit is all the content shared by Xiaobian. I hope it can give you a reference, and I hope you can support developeppaer more.

Recommended Today

PHP 12th week function learning record

sha1() effect sha1()Function to evaluate the value of a stringSHA-1Hash. usage sha1(string,raw) case <?php $str = “Hello”; echo sha1($str); ?> result f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 sha1_file() effect sha1_file()Function calculation fileSHA-1Hash. usage sha1_file(file,raw) case <?php $filename = “test.txt”; $sha1file = sha1_file($filename); echo $sha1file; ?> result aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d similar_text() effect similar_text()Function to calculate the similarity between two strings. usage similar_text(string1,string2,percent) case […]